[SQL ] mysql_fetch_array後只要部分資料?

作者: higgco (higgco)   2017-10-26 13:23:14
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" }]
要怎麼寫呢?感謝
作者: cutekid (可愛小孩子)   2017-10-26 14:00:00
sql 部份,只 select id 和 classify
作者: higgco (higgco)   2017-10-26 17:47:00
謝謝

Links booklink

Contact Us: admin [ a t ] ucptt.com