View Full Version : javascript function does not read any thing from externjson_encode(mysql_fetch_array)

05-25-2012, 04:51 PM

I have 2 php files first file index.php send the selected product_id to edit_order.php to be selected from the mysql DB and the related row be stored into an array and the array will be paged into index php to be loaded into the edit prompt screen to be edited by user and be submited again.

the problem is that, the edit_user.php wont send the query back to index.php

It surly selects the row, as it echo the array for me.

here is the index.php JScript function that sends the product_id

function editRecord(f1) {
var mySite= document.getElementById('rowNu').value
t = './edit_order.php?s=' + mySite;
t = encodeURI (t);
f1.action = t;

and here is the edit_record. php

//include 'delfile.php';


$con = mysql_connect('localhost', 'root', '');
if (!$con)
die('Could not connect: ' . mysql_error());

mysql_select_db("userinfo", $con);
mysql_query("INSERT INTO admin1 unit_price VALUE (34) WHERE product_id = '".$q."'");

$sql = sprintf("SELECT * FROM admin1 WHERE product_id = '".$q."'", $q);

//$sql="SELECT * FROM admin1 WHERE product_id = '".$q."'";
$result = mysql_query($sql);

$row = json_encode(mysql_fetch_array($result));

echo "queryResults('" . $row . "');";
//$rowedit = mysql_fetch_array($result);

here is the code in index.php that suppose to read the json

<script src="edit_order.php?query=jones">
function queryResults(data) {

var results = JSON.parse(data);

prompt(document.write("<p>Unit Price = " + result.unit_price + "</p>"));


I have learnt it fromhttp://www.ehow.com/how_8584143_javascript-mysql-query-via-php.html

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum