PHP 从数据库遍历返回json

<?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 "无记录!";
	}
	
?>

你可能感兴趣的:(返回JSON)