- 0
My Data is not showing on my html page Pin
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
- 3 answers
- 3,245 views
-
QNAP issues patch for an RCE security vulnerability affecting PHP in NAS Drive management
By Alap Naik Desai,
- remote code execution
- rce
- (and 12 more)
- 0 replies
- 6 views
-
Get this Dynamic 2022 Data & IT Security Training Bundle at 97% off
By News Staff,
- neowin deals
- cyber security
- (and 4 more)
- 0 replies
- 6 views
-
Save 98% off this 27 Course Premium Learn to Code Certification Bundle
By News Staff,
- neowin deals
- coding
- (and 10 more)
- 0 replies
- 9 views
-
Get the Complete 2021 Superstar Backend Developer Bundle for only $39.99
By News Staff,
- neowin deals
- sponsored
- (and 7 more)
- 0 replies
- 321 views
-
Question
Salman Memon
<?php
mysql_connect ("localhost", "root", "") or die (mysql_error());
mysql_select_db ("webservices_exmple")or die (mysql_error());
$var = array();
$sql = "SELECT * FROM User";
$result = mysql_query($sql);
while($obj = mysql_fetch_object($result)) {
$var[] = $obj;
}
echo json_encode($var);
?>
// here second page///
<html>
<head>
<script type="text/javascript">
$(document).ready(function(){
var url="getjson.php";
$("#jsondata tbody").html("");
$.getJSON(url,function(data){
$.each(data.User,function(i,data){
var newRow =
"<tr>"
+"<td>"+data.id+"</td>"
+"<td>"+data.name+"</td>"
+"<td>"+data.age+"</td>"
+"<td>"+data.gender+"</td>"
+"</tr>" ;
$(newRow).appendTo("#jsondata tbody");
});
});
});
</script>
</head
<body>
<table class="mGrid" id="jsondata" >
<thead>
<th>Id</th>
<th>Name</th>
<th>Age</th>
<th>Gender</th>
<th>Location</th>
</thead>
<tbody></tbody>
</table>
</body>
</html>
Link to comment
Share on other sites
1 answer to this question
Recommended Posts