View Single Post
  #1 (permalink)  
Old Feb 10th, 2006, 13:37
kal kal is offline
Junior Member
Join Date: Dec 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Drop Down Default Option

Hi

I have coded the following which creates me a database driven drop down menu, however i want to be able have a default option, which is automatically selected based on the value of a varaible.

Any help would be great.

<?php

$query = "select scriptname from script_summary";
$result = mysql_query ($query) or die (mysql_error());
echo "<td><b>Please Select A SCRIPT:</b></td> <td><SELECT name=\"scriptname\">";
if (mysql_num_rows($result)>0)

{
while($row=mysql_fetch_array($result))

{
echo "<option value=\"$row[scriptname]\">$row[scriptname]</option>";
}
}
echo "</SELECT></td>";
?>

Thanks in advance.
Reply With Quote