Welcome Guest, Not a member yet? Register   Sign In
How to display num_rows() and result() in the same Foreach loop
#3

[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
------- ---------
cat1    12
cat2    4
cat3    0

Then just loop through the rows in a foreach displaying row->catname (row->postcount) in your li's.


Messages In This Thread
How to display num_rows() and result() in the same Foreach loop - by El Forum - 08-29-2009, 01:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB