当前位置: 代码迷 >> 综合 >> PHP 从数据库遍历返回json
  详细解决方案

PHP 从数据库遍历返回json

热度:35   发布时间:2024-01-21 17:08:48.0
<?php session_start(); include("conn/conn.php");?>
<?php//Pick out information from database and print out.$type = $_GET['type'];$q_word="select id ,attr_type,pic_url,pic_desc from projectinfo where attr_type='".$type."' order by attr_type";$res=mysql_query($q_word);if ($res){while($row=mysql_fetch_array($res)){// echo $site.'/'.$upload_dir.'/'.$p_name.'/'.$row[attr_type].'/'.$row[pic_url]; $json=json_encode($row);echo $json;}}else{echo "无记录!";}?>