473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Jul 17 '05 #1
2 1702

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Alexander | last post by:
Hello I am new to php & MySQL - I am trying to retrieve some records from a MySQL table and redisplay them. The data in list form looks like this: Sample_ID Marker_ID Variation ...
5
by: build | last post by:
G'day All, I have a problem with this loop. There are a number of .txt files in 'myPath'. tmpFile = Dir(myPath & "\*.txt") 'PROCESS FOLDER Do Until tmpFile = "" <lottsa code> <too much to...
11
by: ritterhaus | last post by:
Just a simple bit of code to toggle between two state at intervals... import time for i in range(4): print 'On' time.sleep(1) print 'Off' time.sleep(1) .... SHOULD toggle On and Off four...
12
by: reynoldscraigr | last post by:
Hi All, hope someone can see what wrong here I have the following function function RemoveMenuFromHoldArray(menuName) { var i = 0; for (i=0;i<=MenusToHoldOpen.length-1;i++) { if...
43
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
63
by: Aaron Ackerman | last post by:
What is the sytax for exiting a for loop in C#?
15
by: Mike Lansdaal | last post by:
I came across a reference on a web site (http://www.personalmicrocosms.com/html/dotnettips.html#richtextbox_lines ) that said to speed up access to a rich text box's lines that you needed to use a...
2
by: d3vkit | last post by:
Okay so I can NOT get my while loop to work. It's the most confusing thing I've ever come across. It was working fine and then suddenly, nothing. No error. The page just dies. I am using PHP5 with...
5
by: sgurukrupagmailcom | last post by:
Hi, I haven't come accross an elegant solution to a design problem that I show below. Have a look at the piece of code here: class Exc { Exc () { System.out.println ("Haribol"); }
1
by: JavaJon | last post by:
Hello, I'm Jon. I've recently picked up Java after using a "gimmick" programming language called GML ( Game Maker Language ). I've read a lot of tutorials and even a Java for Dummies *.pdf book....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.