Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从数组中提取行。?mysqli_Php_Mysql_Codeigniter_Mysqli - Fatal编程技术网

Php 如何从数组中提取行。?mysqli

Php 如何从数组中提取行。?mysqli,php,mysql,codeigniter,mysqli,Php,Mysql,Codeigniter,Mysqli,我正在与codeigniter合作。我想获取一个索引已传递的行。如果我通过0则应显示第一行,如果通过2则显示第二行。等 这是我的小代码 $qu['tid'] = mysqli_query($con , "select * from tablename"); $this->load->view('admin/panel1' , $qu); 查看代码 <table> <tr> <th>ID</th>

我正在与codeigniter合作。我想获取一个索引已传递的行。如果我通过
0
则应显示第一行,如果通过
2
则显示第二行。等

这是我的小代码

$qu['tid'] = mysqli_query($con , "select * from tablename");        
$this->load->view('admin/panel1' , $qu);
查看代码

<table>
    <tr>
        <th>ID</th>
        <th>Name</th>
    </tr>

    <tr>
        <td><?php echo $tid['id'];?></td> // given row if 1 or 2
        <td><?php echo $tid['name'];?></td>// given row if 1 or 2
    </tr>
</table>

身份证件
名称
//给定行(如果为1或2)
//给定行(如果为1或2)

尝试使用
$this->db->get('table\u name')->row\u array()
返回数组格式的第一行

要获取特定行,请将行号作为参数传递

$row = $this->db->get('table_name')->row_array(2);//fetches the third row
示例

控制器:

$qu['tid'] = $this->db->get('table_name')->row_array();        
$this->load->view('admin/panel1' , $qu);
视图:


我想在后面用变量更改它。为什么被否决?有什么解释吗?我想像这样回显一行
echo$tid['id'][0]
,第二行
echo$tid['id'][1]
third
echo$tid['id'][3]
。*如何从整个数组变量中提取特定行?**使用result_array()和foreach循环。
echo $tid['id'];//prints id