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@

> -----Original Message-----
> From: Pavel Kalian [mailto:[EMAIL PROTECTED]]
> Sent: 21 February 2001 15:00
> To: Matt Williams; [EMAIL PROTECTED]; PHP_UK@egroups. com
> Subject: Re: [PHP] array headaches
>
>
> a) $menu[] = array("name" => $db->f("name"), "url" => $db->f("topic_id"));
>
> b) echo $menu[0]["name"]; //for example - depends on what you want to do
>
> BTW have a look into the manual, the array stuff is described pretty well
>
> Pavel
>
> ----- Original Message -----
> From: "Matt Williams" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; "PHP_UK@egroups. com"
> <[EMAIL PROTECTED]>
> Sent: Wednesday, February 21, 2001 3:56 PM
> Subject: [PHP] array headaches
>
>
> > Hi
> >
> > could anybody please help me get my head around the following.
> >
> > I get some url information from the database (title, url)
> > I am trying to then put this into an array so I can pass it to
> the page to
> > display a menu.
> > so
> > a) how do I get the data into the array. would this be the way
> to do it??
> >
> > $menu = array();
> > while($db->next_record())
> > {
> > $menu[]["name"] = $db->f("name");
> > $menu[]["url"] = $db->f("topic_id");
> > }
> > which leads me onto
> > b) how do I get the data back out. I can't test to see if the
> above works
> as
> > I can't get at the data
> >
> > TIA
> >
> > M@
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to