![]() |
How to display num_rows() and result() in the same Foreach loop - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How to display num_rows() and result() in the same Foreach loop (/showthread.php?tid=22083) |
How to display num_rows() and result() in the same Foreach loop - El Forum - 08-28-2009 [eluser]Gwarrior[/eluser] As the title says, I have a custom blog that I've made, and under posts, users are able to select a category. In the side panel, it lists the current categories pulled from a DB Query. In example: View: Code: <ul> I want the <li>'s to foreach loop. How would I go about doing this? What I have now is not even close, so I won't even post it. Thanks! How to display num_rows() and result() in the same Foreach loop - El Forum - 08-28-2009 [eluser]InsiteFX[/eluser] Hi, Please next time show your code for your foreach, it's kind of hard to help without it. But you may be able to do this: Code: $cat_count = 0; Like I said above without seeing your code it's a little hard to help. the above should give you a clue of what you need to do. Enjoy InsiteFX How to display num_rows() and result() in the same Foreach loop - El Forum - 08-29-2009 [eluser]kgill[/eluser] In your query left outer join your categories table to your posts table, selecting a count of posts and the category, group by category. That will give you data like so: Code: catname postcount Then just loop through the rows in a foreach displaying row->catname (row->postcount) in your li's. How to display num_rows() and result() in the same Foreach loop - El Forum - 08-30-2009 [eluser]Gwarrior[/eluser] Thanks for the replies, guys. So for the left outer join, where 'blog_system' = post table name, and blog_categories = post category table, I should do it roughly as such? Below is what I have tried, and it is almost working, but its mixing categories and blog posts I believe. Could you help clean this up to work? Sorry... first left outer join. Code: function get_num_category() { How to display num_rows() and result() in the same Foreach loop - El Forum - 08-30-2009 [eluser]Gwarrior[/eluser] Mispost. |