Rene, This is a clarification of what I think Ignatius was talking about.
I did like this on www.deep-purple.com/tourdates:
Your database structure must look something like this for it to work:
ID ITEM CATEGORY
1 1 1
2 2 1
3 3 1
4 4 1
5 1 2
6 2 2
7 3 2
8 1 3
9 2 3
10 3 3
11 4 3Then you do like this with PHP:
<?php
$SQL = "select * from itemsAndCategories order by CATEGORY, ITEM";
$result = mysql_query($SQL);
$lastCategory = "";
while ($row = mysql_fetch_row($result)) {
if ($lastCategory != $row['CATEGORY']) {
$lastCategory = $row['CATEGORY'];
echo "<b>Category " . $row['CATEGORY'] . "</b><br />\n";
}
echo "Item " . $row['ITEM'] . " of category $lastCategory<br />\n";
}
?>This should generate the list you gave as an example..
Enjoy, Mike
On Apr 20, 2004, at 09:43, Rene Schoenmakers wrote:
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
