How can I get the array data from a JSON sent back by my php script?
PHP code:
<?php
//connects to database
include 'connect.php';
$callback = $_GET['callback'];
$query = mysql_query("SELECT * FROM users");
$rows = array();
while($r = mysql_fetch_assoc($query)) {
$rows[] = $r;
}
$out_string = json_encode($rows);
print $callback.'('.$out_string.');';
?>
The php code above puts all of user table's rows into an array and JSONencodes it. It is then sent back to this script:
$.getJSON(domain_path + 'generate.php?table=' + tbname + '&callback=?', function(data) {
});
How can I display each row from the JSON array sent back?
For example the data will be sent back is:
([{"name":"user1","link":"google.com","approve":"true"},{"name":"user2","link":"yahoo.com","approve":"true"},{"name":"user3","link":"wikipedia.com","approve":"true"}]);
How would I use javascript (jQuery) to display it out like this:
Name: User1 , Link: google.com , Approve:True Name: User2 , Link: yahoo.com , Approve:True Name: User3 , Link: wikipedia.com , Approve:True