看板 Database 關於我們 聯絡資訊
php內寫mysql接收資料 while($row = mysql_fetch_array($result)){ $temp[] = $row; } echo json_encode($temp); 出現的會是 [{"id":"1","classify":"18","mes":"good","name":"mary"}, ] 全部的數據 另一個數據 沒有出現? {"id":"3","classify":"20","mes":"bad","name":"candy"} 若我只想要他出現 id 和 classify請問我要怎麼寫 $temp[] = $row; 這位置 PS:若寫 $temp[] = $row[classify]; 就可以出現兩個數據的classify個別出來 如["18","20"] 所以請問想要他出現 [{"id":"1","classify":"18" },[{"id":"3","classify":"20" }] 要怎麼寫呢?感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.30.127.172 ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1508994640.A.F90.html ※ 發信站: 批踢踢實業坊(ptt.cc) ※ 轉錄者: higgco (163.30.127.172), 10/26/2017 13:23:14 ※ 編輯: higgco (163.30.127.172), 10/26/2017 13:24:23 ※ 編輯: higgco (163.30.127.172), 10/26/2017 13:24:50 higgco:轉錄至看板 PHP 10/26 13:32
cutekid: sql 部份,只 select id 和 classify 10/26 14:00
higgco: 謝謝 10/26 17:47