CodeIgniter 从传递单行到传递多行
我正在使用 CodeIgniter 构建一个网站。我有丰富的使用 SQL 和 PHP 的经验,但在使用 CodeIgniter 时遇到一些问题。
我使用以下代码来设置用户数据以保存数据库中的徽标。
目前我只有 1 个徽标,它工作正常,但我需要对其进行编辑以处理多个徽标。
$query3 = $this->db->query('SELECT file FROM ohes_flyer_logos');
$row3 = $query3->row();
$data = array( 'userlogo' => $row3->file );
$this->session->set_userdata($data);
徽标列出的位置...
echo $this->session->userdata('userlogo');
我如何编辑它以通过完整的徽标列表,并将它们全部回显?
I'm building a site using CodeIgniter. I have lots of experience using SQL with PHP but having some trouble working through CodeIgniter.
I'm using the following code to set userdata to hold a logo from my database.
Currently I only have 1 logo and it works fine but I need to edit it to handle multiple logos.
$query3 = $this->db->query('SELECT file FROM ohes_flyer_logos');
$row3 = $query3->row();
$data = array( 'userlogo' => $row3->file );
$this->session->set_userdata($data);
Where the Logos are listed...
echo $this->session->userdata('userlogo');
How can I edit this to pass through a full list of logos, and echo them all out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用
row()
仅抓取一条记录。您可能想要使用result()
或result_array()
并将其传递到可以循环遍历它们的视图。例如:那么在你看来,你可以这样做:
Calling
row()
grabs only a single record. You probably want to useresult()
orresult_array()
and pass that to the view where you can loop through them. For example:Then in your view, you can do this: