Connecting Tech Pros Worldwide Help | Site Map

loop problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 12:30 AM
raul76@gmx.de
Guest
 
Posts: n/a
Default loop problem

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

  #2  
Old July 17th, 2005, 12:30 AM
Tom Thackrey
Guest
 
Posts: n/a
Default 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)
  #3  
Old July 17th, 2005, 12:30 AM
warstar
Guest
 
Posts: n/a
Default 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]

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.