Tablecloth
asked on
PHP dropdown list not displaying first MySql record
Greetings,
I cannot know why the following code does not return the first record to a dropdown list from a MySql table.
The funny thing is, the commented out code does work.
I am not calling the mysql_fetch_array twice either...
Any help would be appreciated.
Mick
$sqlAuthors="SELECT AuthorID, Author FROM Authors";
$TheResult=mysql_query($sq lAuthors);
$options="";
while ($row=mysql_fetch_array($T heResult))
{
$id=$row["AuthorID"];
$thing=$row["Author"];
$options.="<OPTION VALUE=\"$id\">".$thing.'</ option>';
}
//while ($row=mysql_fetch_array($T heResult))
//{
// $id=$row["AuthorID"];
// $thing=$row["Author"];
//
// echo "Record No. $id is $thing </br>";
// // $options.='<option value="'.$id.'">'.$thing.' </option>' ;
//
//}
echo <<<_END
<form action="DropDownListExampl e.php" method="post">
<SELECT NAME="ddAuthors">
<?=$options?>
</SELECT>
<input type ="submit" value="GetAuthors"/>
</form>
_END;
I cannot know why the following code does not return the first record to a dropdown list from a MySql table.
The funny thing is, the commented out code does work.
I am not calling the mysql_fetch_array twice either...
Any help would be appreciated.
Mick
$sqlAuthors="SELECT AuthorID, Author FROM Authors";
$TheResult=mysql_query($sq
$options="";
while ($row=mysql_fetch_array($T
{
$id=$row["AuthorID"];
$thing=$row["Author"];
$options.="<OPTION VALUE=\"$id\">".$thing.'</
}
//while ($row=mysql_fetch_array($T
//{
// $id=$row["AuthorID"];
// $thing=$row["Author"];
//
// echo "Record No. $id is $thing </br>";
// // $options.='<option value="'.$id.'">'.$thing.'
//
//}
echo <<<_END
<form action="DropDownListExampl
<SELECT NAME="ddAuthors">
<?=$options?>
</SELECT>
<input type ="submit" value="GetAuthors"/>
</form>
_END;
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
trial and error of a weak programmer
Open in new window