Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-25-2012, 03:51 PM   PM User | #1
smaboud
New to the CF scene

 
Join Date: May 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
smaboud is an unknown quantity at this point
javascript function does not read any thing from externjson_encode(mysql_fetch_array)

Hi

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

Code:
function editRecord(f1) {
var mySite= document.getElementById('rowNu').value
t = './edit_order.php?s=' + mySite;
t = encodeURI (t);
f1.action = t;
f1.submit();
}
and here is the edit_record. php
PHP Code:


<?php
//include 'delfile.php'; 

$q=$_GET["s"];

$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);
//setcookie("rowEdit",$rowedit);
?>
here is the code in index.php that suppose to read the json
Code:
<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>"));

}
</script>
I have learnt it fromhttp://www.ehow.com/how_8584143_java...y-via-php.html
smaboud is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript, json, php array

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:03 PM.


Advertisement
Log in to turn off these ads.