By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,738 Members | 1,769 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,738 IT Pros & Developers. It's quick & easy.

loop problem

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

On 11-Oct-2003, ra****@gmx.de (ra****@gmx.de) wrote:
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";
}


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 ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2

P: n/a
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, ra****@gmx.de (ra****@gmx.de) wrote:
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


Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.