Problem with PHP & Drop down boxes
Posted: Tue Jan 30, 2007 12:59 pm
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am new to PHP and programming. I am trying to retrieve information from a mySQL database to display in a single drop down box for the user to select from. With the code below, I retrieve the information, but each row displays separately in its own drop down box! Any information you could supply would be very much appreciated. Thanks in advance.Code: Select all
<html>
<body>
<?php
@ $db = mysql_pconnect('localhost', 'formuser',
'form123db');
mysql_select_db('documents');
$result = mysql_query("SELECT ID, typename FROM typesform");
while($row = mysql_fetch_array($result))
{
echo "Select Citation Type:";
echo "<select> size=40 <option value=" . $row['ID'] . ">" .
$row['typename'] . "</option></select>";
}
?>
</body>
</html>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]