Connecting Tech Pros Worldwide Forums | Help | Site Map

loop problem

raul76@gmx.de
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi,
what is wrong with this part of code?
I wish to get all values from mysql_query, but don't get the first
element, the last one empty...
[the query $raeume works properly]
echo "<select name=\"raum\"> ";
while ($zimmer = mysql_fetch_array($raeume))
{
$z = printf ($zimmer["zimmerID"]);
if ($first = false)
{
echo "<option name=raum type = text selected value=\"$z\">$z\n";
$first = true ;
}
echo "<option name = raum type = text vale = \"$z\">$z\n";
}

TIA
Greetings

Tom Thackrey
Guest
 
Posts: n/a
#2: Jul 17 '05

re: loop problem



On 11-Oct-2003, raul76@gmx.de (raul76@gmx.de) wrote:
[color=blue]
> what is wrong with this part of code?
> I wish to get all values from mysql_query, but don't get the first
> element, the last one empty...
> [the query $raeume works properly]
> echo "<select name=\"raum\"> ";
> while ($zimmer = mysql_fetch_array($raeume))
> {
> $z = printf ($zimmer["zimmerID"]);
> if ($first = false)
> {
> echo "<option name=raum type = text selected value=\"$z\">$z\n";
> $first = true ;
> }
> echo "<option name = raum type = text vale = \"$z\">$z\n";
> }[/color]

You probably want if ($first == false) and an 'else' before the last echo.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)
warstar
Guest
 
Posts: n/a
#3: Jul 17 '05

re: loop problem


maybe this works:

echo "<select name=\"raum\"> ";
while ($zimmer = mysql_fetch_array($raeume))
{
if ($first = false)
{
echo "<option name=raum type = text selected
value='".$zimmer["zimmerID"]."'>'".$zimmer["zimmerID"]."\n";
$first = true ;
}
echo "<option name = raum type = text vale =
''".$zimmer["zimmerID"]."'>'".$zimmer["zimmerID"]."\n";
}

I haven't tested this in any way but maybe u get lucky



On 11 Oct 2003 21:57:55 -0700, raul76@gmx.de (raul76@gmx.de) wrote:
[color=blue]
>Hi,
>what is wrong with this part of code?
>I wish to get all values from mysql_query, but don't get the first
>element, the last one empty...
>[the query $raeume works properly]
>echo "<select name=\"raum\"> ";
>while ($zimmer = mysql_fetch_array($raeume))
>{
> $z = printf ($zimmer["zimmerID"]);
> if ($first = false)
> {
> echo "<option name=raum type = text selected value=\"$z\">$z\n";
> $first = true ;
> }
> echo "<option name = raum type = text vale = \"$z\">$z\n";
>}
>
>TIA
>Greetings[/color]

Closed Thread