It can be done in one query. Just join the two tables, and do a single
loop through that query, printing out each row. When you reach a new
category, display it.
Something like this:
$iCategoryID = -1;
while($aRow = ...)
if($iCategoryID != $aRow['iCategoryID'])
$iCategoryID = $aRow['iCategoryID'];
That's bare bones, but that is, as far as I know, the best way to do it.
Seona Bellamy wrote:
I'm relatively new to php, and am pretty much trying to learn as I go along.
I've been struggling to get my head around this problem for a day and half,
so I'm hoping that someone with more familiarity with the language can help
I have the following two tables:
What I want is to get the name of each category and output that, and then
under each category I want to list the sections that belong to it. So for
- Section 1
- Section 2
- Section 3
- Section 4
Is there a simple way to do this? Do I need to run one query and then run a
second query inside a loop? I have concerns about overheads using this
method, but so far it's the only one I have come up with. I'm open to
suggestions, but please spell everything out clearly because I'm still
<< ella for Spam Control >> has removed Spam messages and set aside Later
You can use it too - and it's FREE! http://www.ellaforspam.com
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.10 - Release Date: 10/01/2005
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php