Use only one query:

SELECT
category,
item,
...
ORDER BY category, item

Now fetch rows, and keep the latest categoryID in a flag variable:
- if fetched categoryID <> flag, close table, create a new table, add header
row
- otherwise add content row to the current table
- update flag with the latest category ID

BTW you may want to use the great PEAR HTML_Table package to generate your
tables.

HTH
_________________________
----- Original Message -----
From: "Rene Schoenmakers" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 20, 2004 10:43 AM
Subject: [PHP-DB] Looping through a result


Hi,

I want to make the following page,

Category 1
Item 1 of category 1
Item 2 of category 1
Item 3 of category 1
Item 4 of category 1

Category 2
Item 1 of category 2
Item 2 of category 2
Item 3 of category 2

Category 3
Item 1 of category 3
Item 2 of category 3
Item 3 of category 3
Item 4 of category 3
Item 4 of category 3,

using PHP and MySQL. Looping through a result is not the problem. But
how do I use a second query while looping through a result and do I have
to use more then 1 table in the database?
Can somebody point me in the right direction?

Tia,

René

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to