Re: array headaches

From: Date: Wed, 21 Feb 2001 23:31:39 +0000
Subject: Re: array headaches
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41080@lists.php.net to get a copy of this message
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@ 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? -- 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

« previous php.general (#41080) next »