RE: [PHP] option tags and WHILE

2001-08-19 Thread Rudolf Visagie

Also

while ($array[1] >= $array[0]) {

and not

while ($array[1] => $array[0]) {

Rudolf Visagie
[EMAIL PROTECTED]

-Original Message-
From: David Robley [mailto:[EMAIL PROTECTED]]
Sent: 20 August 2001 07:01
To: CGI GUY; [EMAIL PROTECTED]
Subject: Re: [PHP] option tags and WHILE


On Mon, 20 Aug 2001 12:23, CGI GUY wrote:
> What's wrong with this code?  I keep getting a parse
> error at the form/select lines...
>
> $array = mysql_fetch_array($mysql_result) or die("no
> go");
>
> print ("");
> print ("");
> while ($array[1] => $array[0]) {
> print (" ">$array[1]\n");
> }
> print ("");
> print ("");
> ?>

That's an, er, interesting script. But it's not going ever to do what I 
think you expect it to.

You need to use while to loop through the rows returned by your SQL 
query, and for each iteration in the while loop, print the values you 
need. Also, if you use extract, you can directly access variables that 
have the same names as the rows in your table, so you don't have to refer 
to array elements.

Frinstance, if you are fetching fields named value and label for this 
exercise, something like:


echo '';
while ($array = mysql_fetch_array($mysql_result)) {
  extract($array);
  echo '' . $label . '';
}
echo '';

Of course, you'll need to put some more info in your  tag and add 
submit buttons and so forth.

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   Ensign Expendable, step on that rock! - Kirk

-- 
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]




Re: [PHP] option tags and WHILE

2001-08-19 Thread David Robley

On Mon, 20 Aug 2001 12:23, CGI GUY wrote:
> What's wrong with this code?  I keep getting a parse
> error at the form/select lines...
>
> $array = mysql_fetch_array($mysql_result) or die("no
> go");
>
> print ("");
> print ("");
> while ($array[1] => $array[0]) {
> print (" ">$array[1]\n");
> }
> print ("");
> print ("");
> ?>

That's an, er, interesting script. But it's not going ever to do what I 
think you expect it to.

You need to use while to loop through the rows returned by your SQL 
query, and for each iteration in the while loop, print the values you 
need. Also, if you use extract, you can directly access variables that 
have the same names as the rows in your table, so you don't have to refer 
to array elements.

Frinstance, if you are fetching fields named value and label for this 
exercise, something like:


echo '';
while ($array = mysql_fetch_array($mysql_result)) {
  extract($array);
  echo '' . $label . '';
}
echo '';

Of course, you'll need to put some more info in your  tag and add 
submit buttons and so forth.

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   Ensign Expendable, step on that rock! - Kirk

-- 
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]