Populating a list box from a database - The code
| From: | Denis L. Menezes | Date: | Sat, 28 Dec 2002 17:18:22 +0000 |
| Subject: | Populating a list box from a database - The code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129511@lists.php.net to get a copy of this message | ||
<select name="OrgName[]" size=5 id="OrgName" >
<?php
//connecting to the database
$link = mysql_connect("localhost","lodestone","trypass");
if ($link){
Print "";
} else {
Print "No connection to the database";
}
if (!mysql_select_db("catapult_com")){
Print "Couldn't connect database";
} else {
Print ""."<br>\n";
}
$sql="SELECT OrgName From TableResults ORDER BY OrgName";
$result=mysql_query($sql);
While($Organisation=mysql_fetch_array($result))
{
Print("<OPTION VALUE=\"$Organisation[0]\">$Organisation[1]\n");
}
?>
</select>