RE: [PHP] array headaches
| From: | Matt Williams | Date: | Thu, 22 Feb 2001 08:54:20 +0000 |
| Subject: | RE: [PHP] array headaches | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41107@lists.php.net to get a copy of this message | ||
<snip>
> Why do you need to put the values in an array, then read through the
> array to print the values? Why not just print each record as you get it
> from the DB?
The array is formed before the page is called. This is then passed to the
page which prints it out.
M@
> On Thu, 22 Feb 2001 02:11, Matt Williams wrote:
> > I have done it this way...
> >
> > $menu = array();
> > $count = $db->num_rows();
> > for($i = 0; $db->next_record(); $i++)
> > {
> > $menu[$i]["name"] = $db->f("name");
> > $menu[$i]["url"] = $db->f("topic_id");
> > }
> >
> > OK, so is there a better way of acheiving the same end result?
> > and this is what I've got to print the results
> >
> > while ( list($name, $subarray) = each($menu) )
> >
> >
> > echo "<a
> >
> > href=\"".$subarray["url"]."\">".$subarray["name"]."<a><br>\n";
> >
> > }
> >
> > is there any better way of doing this??
> >
> > thanks
> >
> > M@
>
>
> --
> David Robley | WEBMASTER & Mail List Admin
> RESEARCH CENTRE FOR INJURY STUDIES |
> http://www.nisu.flinders.edu.au/
> AusEinet |
> http://auseinet.flinders.edu.au/
> Flinders University, ADELAIDE, SOUTH AUSTRALIA
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>