|  | 
	                
  
    | 
	 
        ถ้าเราเรียก json แบบมีข้อมูลเป็นชุดๆ หลายชุดอ่ะค่ะ แล้วต้องมี key ไว้ให้ฝั่ง app ใช้เรียกต้องทำไงบ้างคะ     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | จาก โค้ดนี้ 
 Code (PHP)
 
 <?
	$objConnect = mysql_connect("mysql4.000webhost.com","a7173290_sitny66","218820sinE");
		
	mysql_query("SET NAMES UTF8");
	
	$objDB = mysql_select_db("a7173290_AR");
	$strSQL = "SELECT * FROM building_food WHERE 1  ";
	$objQuery = mysql_query($strSQL);
	$intNumField = mysql_num_fields($objQuery);
	$resultArray = array();
	while($obResult = mysql_fetch_array($objQuery))
	{
		$arrCol = array();
		for($i=0;$i<$intNumField;$i++)
		{
			$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
		}
		array_push($resultArray,$arrCol);
	}
	
	mysql_close($objConnect);
	
  $json = json_encode($resultArray);
  echo substr($json, 1, strlen($json)-2);
?>
 ผลลัพธ์ json ก็จะออกมาประมาณนี้
 
 {"building_id":"1","building_name":"true coffee (\u0e15\u0e36\u0e01\u0e20\u0e32\u0e04\u0e27\u0e34\u0e0a\u0e32\u0e27\u0e34\u0e28\u0e27\u0e01\u0e23\u0e23\u0e21\u0e44\u0e1f\u0e1f\u0e49\u0e32)","latitude":"13.7359396","longitude":"100.5320388","picture":""},{"building_id":"2","building_name":"true coffee (\u0e15\u0e36\u0e01 3)","latitude":"13.7368873","longitude":"100.5326165","picture":""},{"building_id":"3","building_name":"i-canteen","latitude":"13.7366251","longitude":"100.5339695","picture":""},{"building_id":"4","building_name":"\u0e2d\u0e34\u0e19\u0e17\u0e19\u0e34\u0e25","latitude":"13.7356474","longitude":"100.5340211","picture":""} 
 แต่ทีนี้เราอยากให้สามารถเรียกเป็นแบบนี้อ่ะค่ะ
 
 {result:[{building:"1",.....}]} 
 เราจะสร้าง key result ยังไงบ้างคะ
 
 
 
 Tag : PHP, MySQL, iOS
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2014-02-02 20:16:00 | By :
                          sitny66 | View :
                          731 | Reply :
                          1 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 echo '{result:',json_encode($resultArray),'}';
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2014-02-02 20:35:59 | By :
                            itpcc |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |