I am having a problem of MySQL/PHP logic hope someone can help me out.
Let's say I have a web page on which I want to list links to articles and each article falls into one of N main catagories (3-5 but I want the code to be flexible if N changes). I keep all of my article names, urls, timestamps, in a single MySQL table along with an enum column that specifies one of the N possible catagory names for each article.
If I want to pull all of the articles out of MySQL (with only one query of the database) and list them on the page, but grouped by catagory with catagory headers, how should I do that?
I am sure there is a way to sort and echo the array of the MySQL result by the N catagory values in the enum column, but I can't make it work. I am having trouble getting around how to specify a catagory ends and a new one begins when looping through the result array when I don't specify catagory names in the code (since there are N of them). Is there a way to count the N possible enum values in the result array before I actually begin printing array values?
Any ideas?
Thanks in advance,
Erik