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编码此查询的结果给我建议吗? 感谢
答案 0 :(得分:5)
$data = array();
$query = $this->db->query("SELECT * FROM product where modelNumber = '$product_id'");
if ($query->num_rows() > 0) {
foreach($query->result() as $row) {
$data[$row->id] = $row->name;
}
}
$json = json_encode($data);