<?php include"connect.php"; $user_id=$_POST['user']; $query = "SELECT fname,sname FROM info WHERE userid = '$user_id' "; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ $fname= $row['fname']; $sname= $row['sname']; $results[] = array("sname" => $fname, "fname" => $sname); } header('Content-type:application/json'); exit(json_encode($results)); ?>
<script> $(function(){ // Don't worry about this $.ajax({ url: 'list.php', //the script to call to get data data: "?user=5778", //5778 is a sample data to pass to list.php dataType: 'json', //data format success: function(data) //on recieve of reply { var html, comment; for(var i = 0; i < data.length; i++) { comment = data[i]; html += '<td>'+ comment.id + '</td><td>' + comment.vname + '</td><td> details</td>' } $('#output1').html(html); } }); }); </script>
<tr>
html += '<tr><td>'+ comment.id + '</td><td>' + comment.vname + '</td><td> details</td></tr>'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)