[thelist] help w/design of SQL query

rudy r937 at interlog.com
Fri Nov 15 09:30:01 CST 2002


> Which is great - but how do I display them like this:

well, with php, i'm afraid you have to write your own code

> So wouldn't I have to get the categories first?
> Then run a query on each category?

AAACK!!  no

if you ever find yourself calling the database repetitively from inside a
loop, chances are really good that there's a much easier way, to say
nothing of more efficient

what you want to do is sequence your results by category, and within
category by item

     order by category, item

then, when you are processing the result set, you have to detect a category
"break" from one row to the next, and do the "new category" logic,
which in your case means printing out the category name

make sense?


rudy





More information about the thelist mailing list