Login Register






Using AJAX? filter_list
Author
Message
Using AJAX? #1
How do I make ajax return multiple rows from a mysql table. So far my query works but I can only get it to return one row.

What I have right now is this for my PHP:
Code:
<?php session_start(); mysql_connect('localhost','root','') or die(mysql_error()); mysql_select_db("quackbook") or die(mysql_error()); if(isset($_SESSION["user"]) === FALSE){ header("location: index.php"); } $find = "SELECT Firstname,Post FROM wall LEFT JOIN info ON info.Username=wall.Username"; $arrow = mysql_query($find); $array = array(); $i = 0; $j=0; while($fire = mysql_fetch_array($arrow)){ $array[$i] = $fire; $i+1; } echo json_encode($array[$i]); ?> And this is my JS: var post,dispost; var ready; window.onload=function(){ hunt(); setInterval(change,500); }; function change(){ dispost.innerHTML= post; }; function hunt(){ xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET","Classes/class.wall.php",true); xmlhttp.send(); xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4 && xmlhttp.status==200){ ready= JSON.parse(xmlhttp.responseText); begin(); } }; }; function begin(){ post=ready["Firstname"]+" posted: "+ready["Post"]+"<br><br>"; dispost=document.getElementById("dispost"); };

Reply

Using AJAX? #2
How do I make ajax return multiple rows from a mysql table. So far my query works but I can only get it to return one row.

What I have right now is this for my PHP:
Code:
<?php session_start(); mysql_connect('localhost','root','') or die(mysql_error()); mysql_select_db("quackbook") or die(mysql_error()); if(isset($_SESSION["user"]) === FALSE){ header("location: index.php"); } $find = "SELECT Firstname,Post FROM wall LEFT JOIN info ON info.Username=wall.Username"; $arrow = mysql_query($find); $array = array(); $i = 0; $j=0; while($fire = mysql_fetch_array($arrow)){ $array[$i] = $fire; $i+1; } echo json_encode($array[$i]); ?> And this is my JS: var post,dispost; var ready; window.onload=function(){ hunt(); setInterval(change,500); }; function change(){ dispost.innerHTML= post; }; function hunt(){ xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET","Classes/class.wall.php",true); xmlhttp.send(); xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4 && xmlhttp.status==200){ ready= JSON.parse(xmlhttp.responseText); begin(); } }; }; function begin(){ post=ready["Firstname"]+" posted: "+ready["Post"]+"<br><br>"; dispost=document.getElementById("dispost"); };

Reply

Using AJAX? #3
How do I make ajax return multiple rows from a mysql table. So far my query works but I can only get it to return one row.

What I have right now is this for my PHP:
Code:
<?php session_start(); mysql_connect('localhost','root','') or die(mysql_error()); mysql_select_db("quackbook") or die(mysql_error()); if(isset($_SESSION["user"]) === FALSE){ header("location: index.php"); } $find = "SELECT Firstname,Post FROM wall LEFT JOIN info ON info.Username=wall.Username"; $arrow = mysql_query($find); $array = array(); $i = 0; $j=0; while($fire = mysql_fetch_array($arrow)){ $array[$i] = $fire; $i+1; } echo json_encode($array[$i]); ?> And this is my JS: var post,dispost; var ready; window.onload=function(){ hunt(); setInterval(change,500); }; function change(){ dispost.innerHTML= post; }; function hunt(){ xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET","Classes/class.wall.php",true); xmlhttp.send(); xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4 && xmlhttp.status==200){ ready= JSON.parse(xmlhttp.responseText); begin(); } }; }; function begin(){ post=ready["Firstname"]+" posted: "+ready["Post"]+"<br><br>"; dispost=document.getElementById("dispost"); };

Reply

RE: Using AJAX? #4
This might help you http://stackoverflow.com/questions/96140...-with-ajax
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Using AJAX? #5
This might help you http://stackoverflow.com/questions/96140...-with-ajax
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Using AJAX? #6
This might help you http://stackoverflow.com/questions/96140...-with-ajax
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Using AJAX? #7
It's better to post your code. If we can't check how you handle the data that was transferred it's just guessing. Did you use firebug to check what data is returned?

Reply

RE: Using AJAX? #8
It's better to post your code. If we can't check how you handle the data that was transferred it's just guessing. Did you use firebug to check what data is returned?

Reply

RE: Using AJAX? #9
It's better to post your code. If we can't check how you handle the data that was transferred it's just guessing. Did you use firebug to check what data is returned?

Reply

RE: Using AJAX? #10
Here is the code:

Code:
<?php session_start(); mysql_connect('localhost','root','') or die(mysql_error()); mysql_select_db("quackbook") or die(mysql_error()); if(isset($_SESSION["user"]) === FALSE){ header("location: index.php"); } $find = "SELECT Firstname,Post FROM wall LEFT JOIN info ON info.Username=wall.Username"; $arrow = mysql_query($find); $array = array(); $i = 0; $j=0; while($fire = mysql_fetch_array($arrow)){ $array[$i] = $fire; $i+1; } echo json_encode($array[$i]); ?>

Reply