Re: help gurus: multi-dimensional array problem.

From: Date: Sat, 03 Mar 2001 19:49:13 +0000
Subject: Re: help gurus: multi-dimensional array problem.
Groups: php.general 
Request: Send a blank email to php-general+get-42467@lists.php.net to get a copy of this message
Addressed to: andrew <andrew@salamander.net> php-general@lists.php.net ** Reply to note from andrew <andrew@salamander.net> Sat, 03 Mar 2001 14:26:30 -0500 > > help! :)> > > I'm trying to return a list of links under associated categories from a > database table that has the fields: "linkID, category, name, url". > > I'm selecting the fields and then trying to construct a multi-dimensional > array so that the correct items get put into it (and then printed out): > Why build an array, and store ANOTHER copy of all the data in memory while the script runs? That is just a waste of memory... SELECT Category, Name, URL FROM Links ORDER BY Category, Name; To display them: $OldCategory = ''; while( list( $Category, $Name, $URL ) = mysql_fetch_row( $Result )) { if( $OldCategory != $Category ) { print "Category Header $Category<BR>\n"; $OldCategory = $Category; } print "<A href=\"$URL\">$Name</a><BR>\n"; } Rick Widmer Internet Marketing Specialists http://www.developersdesk.com

« previous php.general (#42467) next »