I have a list of links in MySQL, as ID, category, Description & URL,
Q. How can i generate a list in PHP which breaks the list down by category & which enters the category as the header. i.e.
LINKS
Search Pages
Google.com
MSN.com
PHP Sites
devnetwork.com
PHP.net
etc.
I only have around 4 categories so could easily have 4 connections on my page (where category = 1, 2, 3 or 4) & list them that way.
Is this the easiest way to do it? what if i have 40 categories???
Sort list into groups & break between different groups
Moderator: General Moderators
You could do a search for all links and categories, and order it by category. Then, when looping through the result set rows, store the current category. If the category for the current row != the current category, output a header.
You could also just do 4 different queries.
You could also just do 4 different queries.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: