This is a discussion on "Drop Down Default Option" within the PHP Forum section. This forum, and the thread "Drop Down Default Option are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Drop Down Default Option
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
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. |
|
|
|
#2
|
|||
|
|||
|
Re: Drop Down Default Option
I use something like the following, changed to replicate your code but not tested.
Last edited by Rob; Feb 17th, 2006 at 01:05. |
|
#3
|
|||
|
|||
|
Re: Drop Down Default Option
Cheers mate, i got it working.
|
![]() |
| Tags |
| drop, down, default, option |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Setting a default image size using CSS? | Inkers | Web Page Design | 4 | Oct 12th, 2007 15:10 |
| example of editing in DataGrid and Default Paging | hanusoft | ASP.NET Forum | 1 | Oct 4th, 2007 13:41 |
| Resetting webserver to default !!!!!! | EnSComputers | Starting Out | 3 | Apr 23rd, 2007 12:25 |
| How to set default size for html page? | mohabitar | Web Page Design | 5 | Mar 11th, 2007 19:12 |
| what is default sqlserver username & password ? | clickme_not | Databases | 1 | Aug 27th, 2006 17:57 |