开发者

How can I json_encode the results of this query?

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;
    }
}
}

Can someone give me advice as to how I would json e开发者_JAVA技巧ncode the results of this query? Thanks


$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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜