标签:
JS:
$.get(url,function(data){
var data = eval(data);
$.each(data, function(i, item) {
alert(data[i].x);
});
});
PHP:
<?php
mysql_connect("127.0.0.1", "xxx", "xxx");
mysql_select_db("pinglun");
mysql_query("set names ‘utf8‘");
$sql_sec = "SELECT * FROM think_comment WHERE scence=".$_GET[‘scence‘]." ORDER BY createtime DESC";
$res_sec = mysql_query($sql_sec);
$tiaoshu = 100; //此处控制显示条数
//每次循环将一条数据放入目标数组的一个数组
for ($i = 0; $i < $tiaoshu; $i++) {
$row = mysql_fetch_array($res_sec);
if($row==null){
break;
}
$arr[$i]=array(
‘x‘=>$row[‘ath‘],
‘y‘=>$row[‘atv‘],
‘cont‘=>$row[‘content‘],
‘imgurl‘=>$row[‘imgurl‘],
‘id‘=>$row[‘id‘],
);
}
echo json_encode($arr);
标签:
原文地址:http://www.cnblogs.com/yangchong/p/5340516.html