2
foreach($hello_world as $key=>$product_id) {
if(in_array($key,$exclude))continue;
$query = $this->db->query("SELECT * FROM product where modelNumber = '$product_id'");
if ($query->num_rows() > 0) {
foreach($query->result() as $row) {
echo $row->name;
}
}
}
有人可以給我建議,我將如何編碼這個查詢的結果? 謝謝我該如何json_encode這個查詢的結果?
**警告**您的代碼似乎易受sql注入攻擊。 –
嘗試將結果對象作爲數組轉換並將其傳遞給json_encode()? –
這個問題看起來很相似,第一個答案似乎是相關的;如果你有更具體的需求,也許你可以更新你的問題? http://stackoverflow.com/questions/383631/json-encode-mysql-results –