Re: help gurus: multi-dimensional array problem.
| From: | andrew | Date: | Sat, 03 Mar 2001 19:58:37 +0000 |
| Subject: | Re: help gurus: multi-dimensional array problem. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42468@lists.php.net to get a copy of this message | ||
Because I want to display it like this:
category1 (href anchor to category1 below)
category2
category3
category1
link1
link2
link3
category2
link1
etc...
On 3/3/01 2:49 PM, "php3@developersdesk.com" <php3@developersdesk.com>
wrote:
> 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