Posted by gerg on 05/09/06 10:32
I've got a function that creates a form with a drop down list of values
selected from a database.
function form_MS($formname, $method, $action){
$sql = "SELECT orders.MS FROM orders;";
$result = @mysql_query($sql);
$numrows = @mysql_num_rows($result);
if ($numrows == NULL){
return (false);
}
else
{
$my_baby = @mysql_fetch_array($result);
echo ("<form name=\"$formname\" method=\"$method\" action=\"$action\">\n");
echo ("<select name=\"MS\">\n");
foreach($my_baby as $baby){
echo ("<option value=\"$baby\">$baby</option>\n");
}
echo ("</select>\n");
echo ("</form>\n");
}
}
there are three records in the DB. But the form ends up looking like this:
<form action="someaction" method="somemethod" name="somename>
<selcect name="MS">
<option value="123456">123456</option>
<option value="123456">123456</option>
</select>
</form>
So it's only selecting the first record and echoing it twice.
thanks in advance for any help.
Greg
Navigation:
[Reply to this message]
|