question on listbox.
| From: | Denis L. Menezes | Date: | Sat, 01 Feb 2003 11:08:16 +0000 |
| Subject: | question on listbox. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-133862@lists.php.net to get a copy of this message | ||
Hello friends.
I have a listbox which I populate from a query with the database. It is working fine. But
additinally, I want the first item to be "Select category". Can someone please help me how
to modify by below written code to do the above?
My code : Quote :
<?php
//connecting to the database
$link = mysql_connect("localhost","MyDomain","MyPass");
if ($link){
Print "";
} else {
Print "No connection to the database";
}
if (!mysql_select_db("MyDomain_com")){
Print "Couldn't connect database";
} else {
Print ""."<br>\n";
}
$sql="SELECT DISTINCT CategoryName From Categories ORDER BY CategoryName";
$result=mysql_query($sql);
While($Category=mysql_fetch_array($result))
{
Print("<OPTION VALUE=\"$Category[0]\">$Category[0]\n");
}
?>
Unquote
Thanks very much
Denis