include_once("connect.php"); //连接数据库 //查询数据表中最新的50条记录 $query = mysql_query("select pic from photobooth order by id desc limit 50"); while($row=mysql_fetch_array($query)){ $arr[] = array( 'pic' => $row['pic'] ); } //输出json数据 echo json_encode($arr);
最后,附上数据photobooth结构:
CREATE TABLE `photobooth` ( `id` int(11) NOT NULL auto_increment, `pic` varchar(50) NOT NULL, `uploadtime` int(10) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
您可能感兴趣的文章: