CodeIgniter Forums
displaying distinct() results - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: displaying distinct() results (/thread-28454.html)



displaying distinct() results - El Forum - 03-11-2010

[eluser]elaniobro[/eluser]
I believe that I am set up correctly but my foreach loop is not displaying distinct results only.

controller:
Code:
function index()
        {
            
            
            $data['page'] = 'thoughts';
            $data['query'] = $this->db->order_by('id DESC')->get('thoughts');
            $data['tag'] = $this->db->distinct('tag')->get('thoughts');

            $this->load->view('header', $data);
            $this->load->view('campaign');
            $this->load->view('thoughts_view', $data);
            $this->load->view('footer');
            
        }

and the foreach loop in the view:
Code:
<ul>
                            Tags:<br />
                            <ul>
                            &lt;?php foreach($tag->result() as $row):?&gt;
                            <li>&lt;?= $row->tag?&gt;</li>
                            &lt;?php endforeach;?&gt;
                            </ul>
                        </ul>

Not getting any errors, so I assume the syntax is correct, but apparently my implementation of it is not.