TED]
www.phpbeginner.com
-Original Message-
From: Matt Williams [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 21, 2001 11:57 PM
To: [EMAIL PROTECTED]; PHP_UK@egroups. com
Subject: [PHP] array headaches
Hi
could anybody please help me get my head around the following.
I get some
> 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, 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"
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
> while($db->next_record())
> {
> $menu[]["name"] = $db->f("name");
> $menu[]["url"] = $db->f("topic_id");
> }
Why not use a for loop instead?
for($i = 0; $db->next_record(); $i++) {
$menu[$i]["name"] = $db->f("name");
$menu[$i]["url"] = $db->f("topic_id");
}
Then you can access them thro
ll
>
> 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 he
el
- 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
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??
8 matches
Mail list logo