我的数据没有显示在我的html页面上 [英] My Data is not showing on my html page

查看:104
本文介绍了我的数据没有显示在我的html页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?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);

?>



///////// my我要显示数据的html页面//////


///////// my html page where i want to show the data //////

<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>

</body>
</html>

<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>

推荐答案

var = array();

var = array();


sql = SELECT * FROM User;

sql = "SELECT * FROM User";


result = mysql_query(
result = mysql_query(


这篇关于我的数据没有显示在我的html页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆