Codeigniter 2.x,数据库,打印结果的内容

时间:2015-02-12 03:39:07

标签: php codeigniter-2

我有一个控制器如下:

 $data['query']              = $this->model_admin->search_countries($config['per_page'] , $offset, $sort_by, $sort_order);
    $data['templateVersion']    = 'template1';
    $data['headerVersion']      = 'header1';
    $data['navBarVersion']      = 'navbar1';
    $data['main_content']       = 'detail-wrap/admin/country_index'; $this->load->view('detail-wrap/includes/template1', $data); 

search_countries方法位于控制器中,如下所示:

return $this->db->select('country_id, country')->from('mhcountry')->get()->result();

我的观点如下:

<tbody>

    <?php

    var_dump($query);
    foreach ($query['rows'] as $row ) {
        ?>
    <tr>
        <td><?php echo $row->country_id; ?></td>
        <td><?php echo $row['country']; ?></td>
        <td>something</td>
        <td>someone</td>
    </tr>

    <?php } ?>

</tbody>

我无法显示country_idcountry。我尝试了很多技术,但没有去。 var_dump($query);的内容是正确的,并显示:

Found Countries array(20) { [0]=> object(stdClass)#21 (2) { ["country_id"]=> string(1) "1" ["country"]=> string(6) "Canada" } [1]=> object(stdClass)#22 (2) { ["country_id"]=> string(1) "2" ["country"]=> string(5) "Japan" } [2]=> object(stdClass)#23 (2) { ["country_id"]=> string(1) "3" ["country"]=> string(5) "Korea" } [3]=> object(stdClass)#24 (2) { ["country_id"]=> string(1) "4" ["country"]=> string(1) "0" } [4]=> object(stdClass)#25 (2) { ["country_id"]=> string(1) "5" ["country"]=> string(6) "pakist" } [5]=> object(stdClass)#26 (2) { ["country_id"]=> string(1) "6" ["country"]=> string(6) "ddsdsd" } [6]=> object(stdClass)#27 (2) { ["country_id"]=> string(1) "7" ["country"]=> string(5) "texas" } [7]=> object(stdClass)#28 (2) { ["country_id"]=> string(1) "8" ["country"]=> string(8) "scotland" } [8]=> object(stdClass)#29 (2) { ["country_id"]=> string(1) "9" ["country"]=> string(8) "scotland" } [9]=> object(stdClass)#30 (2) { ["country_id"]=> string(2) "10" ["country"]=> string(8) "scotland" } [10]=> object(stdClass)#31 (2) { ["country_id"]=> string(2) "11" ["country"]=> string(8) "texassss" } [11]=> object(stdClass)#32 (2) { ["country_id"]=> string(2) "12" ["country"]=> string(14) "texassdsdsdsds" } [12]=> object(stdClass)#33 (2) { ["country_id"]=> string(2) "13" ["country"]=> string(11) "cuncuncunuc" } [13]=> object(stdClass)#34 (2) { ["country_id"]=> string(2) "14" ["country"]=> string(1) "d" } [14]=> object(stdClass)#35 (2) { ["country_id"]=> string(2) "15" ["country"]=> string(1) "a" } [15]=> object(stdClass)#36 (2) { ["country_id"]=> string(2) "16" ["country"]=> string(4) "sdsd" } [16]=> object(stdClass)#37 (2) { ["country_id"]=> string(2) "17" ["country"]=> string(9) "scotlands" } [17]=> object(stdClass)#38 (2) { ["country_id"]=> string(2) "18" ["country"]=> string(11) "scotlandsss" } [18]=> object(stdClass)#39 (2) { ["country_id"]=> string(2) "19" ["country"]=> string(6) "asdasd" } [19]=> object(stdClass)#40 (2) { ["country_id"]=> string(2) "20" ["country"]=> string(21) "scotlandsssssssssssss" } }

任何帮助非常感谢。

0 个答案:

没有答案