|
Posted by Geoff Berrow on 10/14/05 20:43
I noticed that Message-ID:
<434fe092$0$13347$4fafbaef@reader2.news.tin.it> from none
<""neri\"@(none)"> contained the following:
>Let's say i want a <form><select> where each option value is taken
>straight from a mysql table.
>
>I have table "letters" (a,b,c,...) and I want the select options to be
>a,b,c...
>
>Can I do these? And how?
>Thanks,
<?php
$sql= "SELECT DISTINCT column FROM `table`";
$result=mysql_query($sql) or die("could not query database");
print"<select name='select'>\n<option>Select option</option>\n";
while($myrow=mysql_fetch_row($result)){
if($myrow[0]==$_POST['select']){
$selected=" selected";
}
else{
$selected="";
}
print"<option$selected>".$myrow[0]."</option>\n";
}
print"</select>\n";
?>
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
[Back to original message]
|