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 –