I have stored 6 records in mysql db,when i use this code each of the 6 records getting displayed in seprate drop down box,i want them to be displayed in a single drop down box.Where am i going wrong? Any help ii be appreciated. Thnx in advance.
A:
On line 17, you should have multiple options printed, with one select and one end-select.
MJB
2010-04-06 17:24:00
Tried,this.I would like to know some thing.Wen i dont get a right answer.Simply accepting it as correct answer make any sense?
DAFFODIL
2010-04-06 17:54:14
No, of course not. But the other commenters are suggesting that you accept VALID answers. You've asked a dozen questions and accepted zero answers. That sounds suspect. Regardless, if it does not work, what error or what behavior are you seeing?
MJB
2010-04-06 18:55:22
I am newbie and how do,i upvote or accept.Can,you explain me.
DAFFODIL
2010-04-07 06:08:51
When you ask a question, there is a clear checkbox to the left of each answer. Click it to accept that answer, and it will become green. If you did not ask the question but you feel the answer given is a good and useful answer, you can click the up arrow above the count on the left (here it is 0). Or if the answer is useless or wrong, you can click the down arrow below the count. You can also up-vote a comment, which you would do by clicking the arrow to the left of the comment. Try it -- you can undo it if you change your mind.
MJB
2010-04-07 12:29:58
+1
A:
You want to do something like this:
<select>
while ($row = mysql_fetch_array($result)) {
echo "<option><!-- put option text here --></option>\n";
}
</select>
webbiedave
2010-04-06 17:24:02
Would you like me to guess what the error is or do you want to give me a hint?
webbiedave
2010-04-06 18:25:35
Probably he inserted the <select> verbatime into a PHP block and got a syntax error.
Marc B
2010-04-06 21:44:45
<?php// Create the connection and select the DB$con = mysql_connect("localhost","root","");if ($con) { mysql_selectdb("form",$con); // Select records from the DB $query = "SELECT * FROM customer"; $result = mysql_query($query); // Display records from the table print "<p>Select a customer:\n"; <select> while ($row = mysql_fetch_array($result)) { echo "<option>$row[0],$row[1],$row[2],$row[3]$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10],$row[11]</option>\n"; } </select>} ?>This is how,i addedd it.
DAFFODIL
2010-04-07 06:09:42
@DAFFODIL -- no, you didn't accept it yet. See my comments below for how to do so, or read the SO FAQ.
MJB
2010-04-07 13:16:46
A:
You need to put the select outside of the for loop. Just the option tag and it's contents should be written in the loop.
unholysampler
2010-04-06 17:24:09