|
|
|
|
![]() ![]() |
Apr 25 2007, 11:35 PM
Post
#1
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 31 Joined: 9-August 06 Member No.: 28,049 |
suppose i make a dropdown menu having value 1, 2, 3, 4, 5, one option can be selected, and selected option is stored in database.
now i create an edit page, how do i display the selected value in the menu and other values in dropdown, for example, Menu is like Select One 1 2 3 4 5 and i select 3, this 3 is stored in database, now on the edit page i want to show 3 as already selected, something like that.. QUOTE <select name="select_thing"> <option value="1">1</option> <option value="2">2</option> <option value="3" selected>3</option> <option value="4">4</option> <option value="5">5</option> </select> I will be very thankful, if someone could help by explaining how do i make option 3 as selected.. eg. how i know option 3 is selected and stored in db. |
|
|
|
Apr 26 2007, 12:54 AM
Post
#2
|
|
|
$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 6,305 Joined: 21-September 04 From: 9r33|\| 399$ 4|\|D 5P4/\/\ Member No.: 1,218 ![]() |
Here are some links to help you out.
This is a wizard that designs a php drop down menu http://www.thesitewizard.com/wizards/navigationmenu.shtml This is a script that creates a dhtml drop down menu http://www.scriptdungeon.com/script.php?ScriptID=1010 This site talks about what goes into a php drop down menu and provides files as well http://www.phpclasses.org/browse/package/1562.html Hopefully that helps give you an idea on what to look for in designing a php drop down menu GOOGLE KEYWORDS "drop down menu in php" |
|
|
|
May 12 2007, 07:02 PM
Post
#3
|
|
|
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 975 Joined: 25-September 05 From: The dungeon deep below the foundation of trap17 Member No.: 12,251 |
Couldn't you just make an if statement? If you know how to get and set the values in the database already, all you'd have to do is somthing like:
CODE <select name="select_thing"> <option value="1"<?php if(mysql_result($result,"","value")==1) echo" selected"; ?>>1</option> <option value="2"<?php if(mysql_result($result,"","value")==2) echo" selected"; ?>>2</option> <option value="3"<?php if(mysql_result($result,"","value")==3) echo" selected"; ?>>3</option> <option value="4"<?php if(mysql_result($result,"","value")==4) echo" selected"; ?>>4</option> <option value="5"<?php if(mysql_result($result,"","value")==5) echo" selected"; ?>>5</option> </select> If that's what you meant, here's a more code-conserving way of writing it: CODE <?php ${mysql_result($result,"","value)}=" selected";?>
<select name="select_thing"> <option value="1"<? echo $1 ?>>1</option> <option value="2"<? echo $2 ?>>2</option> <option value="3"<? echo $3 ?>>3</option> <option value="4"<? echo $4 ?>>4</option> <option value="5"<? echo $5 ?>>5</option> </select> |
|
|
|
May 18 2007, 08:00 PM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 775 Joined: 13-April 07 From: mreža Member No.: 41,558 |
OK this solution will work also I encourage you to try it it looks more simple to me then others. I cannot tell is it because I use it and I am familiar with it or just because it is simpler then other.
Good luck with whatever you are doing For the script I think that it doesn't need any more explanation also I would like to point out that I took in count that when you have loaded this value from your database that then you have saved it in the initial_var that is initial variable. CODE <select name="testlist">
<option <? if(initial_var == "1"){ echo 'selected'; } >? >1</option> <option <? else if(initial_var == "2"){ echo 'selected'; } >? >2</option> <option <? else if(initial_var == "3"){ echo 'selected'; } >? >3</option> <option <? else if(initial_var == "4"){ echo 'selected'; } >? >4</option> <option <? else{ echo 'selected'; } >? >5</option> </select> |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 25th July 2008 - 08:08 PM |