|
|
|
|
![]() ![]() |
![]() ![]() Group: Members
Posts: 32 Joined: 9-August 06 Member No.: 28,049 |
Post
#1
Apr 25 2007, 11:35 PM
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. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [MODERATOR]
Posts: 7,255 Joined: 21-September 04 From: 9r33|\| 399$ 4|\|D 5P4/\/\ Member No.: 1,218 myCENT:83.20 |
Post
#2
Apr 26 2007, 12:54 AM
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" |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [MODERATOR]
Posts: 1,316 Joined: 25-September 05 From: Los Angeles, California Member No.: 12,251 myCENT:59.43 |
Post
#3
May 12 2007, 07:02 PM
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> |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED]
Posts: 786 Joined: 13-April 07 From: mreža Member No.: 41,558 |
Post
#4
May 18 2007, 08:00 PM
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
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
17 | holyium | 8,370 | 1st January 2005 - 10:08 AM Last post by: hulunes |
|||
![]() |
1 | neeki4444 | 5,365 | 18th March 2005 - 02:25 AM Last post by: andrewsmithy |
|||
![]() |
1 | misterhh | 982 | 8th August 2007 - 08:47 AM Last post by: truefusion |
|||
![]() |
6 | YSR | 2,028 | 16th December 2008 - 07:59 PM Last post by: minimcmonkey |
|||
![]() |
3 | --Stealth-- | 2,099 | 6th March 2008 - 06:57 PM Last post by: FeedBacker |
|||
![]() |
6 | SmUX | 3,300 | 21st December 2004 - 02:14 AM Last post by: chiclete |
|||
![]() |
1 | desimela | 4,976 | 7th December 2004 - 01:54 AM Last post by: icedragn |
|||
![]() |
3 | techfreakorama | 1,224 | 29th March 2009 - 09:57 AM Last post by: flashy |
|||
![]() |
11 | karlo | 7,719 | 23rd January 2005 - 04:29 PM Last post by: popac |
|||
![]() |
0 | thablkpanda | 3,839 | 5th February 2005 - 09:02 PM Last post by: thablkpanda |
|||
![]() |
1 | guangdian | 2,271 | 13th February 2005 - 07:05 AM Last post by: guangdian |
|||
![]() |
2 | miCRoSCoPiC^eaRthLinG | 2,257 | 2nd July 2005 - 05:31 PM Last post by: miCRoSCoPiC^eaRthLinG |
|||
![]() |
1 | carrot | 1,523 | 5th March 2005 - 04:21 AM Last post by: canute24 |
|||
![]() |
4 | alexia | 3,956 | 8th March 2005 - 05:23 AM Last post by: karlo |
|||
![]() |
2 | nickmealey | 3,518 | 29th May 2008 - 06:09 AM Last post by: FeedBacker |
|||
|
Open Discussion | Time is now: 8th November 2009 - 12:51 PM |
Web Hosting Powered by ComputingHost.com.