如何在phpmyadmin中显示查询结果?

时间:2014-04-30 15:27:07

标签: codeigniter phpmyadmin

模型

$q2 = "SELECT a.id, name, price FROM product a inner join detail b 
on a.id = b.id
WHERE a.id IN ('".$id."') and status = 1 ";
$result = $this->db->query($q2);
return $result->result_array();

其中$ id = 41001,41002

所以,我尝试进入phpmyadmin。这是结果

的phpmyadmin

SELECT a.id, name, priceFROM product a inner join detail b 
on a.id = b.id
WHERE a.id IN (41001,41002) and status = 1 

该查询的结果是:

id     name        price
41001  Coca Cola   4500
41002  Pepsi       4500

查看

<?php foreach($resultsearch as $r){?>
  <li class="span3">
    <div class="product-box">
      <?php echo $r['id']?>
      <?php echo $r['name']?><span><br/>
      <span>Rp. <?php echo number_format($r['price'],2,",",".")?></span><br/>
    </div>
  </li>       
 <?php $no++;}?>

但是,只显示

41001  Coca Cola   4500

如何在phpmyadmin中显示查询结果?

2 个答案:

答案 0 :(得分:0)

尝试

echo $result->num_rows();

如果结果为2,那么您在控制器中遇到问题,您必须具有以下内容:

$this->load->view('myview', Array('resultsearch' => $this->MYMODEL->myquerymethod($id)));

答案 1 :(得分:0)

尝试这样的查询

$q2 = "SELECT a.id, name, price FROM product a inner join detail b 
on a.id = b.id
WHERE a.id IN (".$id.") and status = 1 ";
$result = $this->db->query($q2);
return $result->result_array();