Jul 25, 2008

Editing Drop Down Menu In Php

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Editing Drop Down Menu In Php

apple
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.

 

 

 


Reply

Saint_Michael
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"

Reply

galexcd
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>

 

 

 


Reply

hitmanblood
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>

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : editing menu php

  1. Can I Make Dynamic Menu In Php - is it posible to make dynamic menu in php without javascript (7)
    As there are many java script by which we can have event based interaction like,message on mouse
    over etc,that we can create dynamic menu in javascripts to make navigation bar ,but is it possible
    in php to have this acomplished without javascripts,i am new to php,is it possible?. Thanks...
  2. Php And Flash Image Gallery - Need some help in creating or editing an xml file while viewing some o (5)
  3. Editing Information In A Mysql Database And Deleting Rows - (5)
    I need help with a couple of things. First, I need to know how to retrieve information from a mysql
    database and edit it then re add it to the database. I also would like to know how to easily delete
    a mysql row. And I want this done without going to phpMyAdmin. Thanks for the help!...
  4. Pulldown Menu - get a realiable php pulldown menu script (8)
    does anyone know where i can get a really good, reliable pulldown php script. one that is cross
    browser compatible. you know the drill, mac - pc, bla bla bla. I'm starting a site right now
    would like to start it off right. round ...
  5. I Need A Php Editor - I need that for image editing (1)
    I need a php editor whichc can be used for the image editing like FrontPage for HTML. Can any body
    give a link for that...
  6. Editing Footer.php - adding a script (2)
    hey can somebody put this script into my footer.php file? because i don't know how. the script
    has to go between the and ok this is the script... CODE <!-- Clicksor.com Advertising
    Code Begin --> <script type='text/javascript'> <!--
    clicksor_layer_border_color = '#B4D0DC'; clicksor_layer_ad_bg = '#ECF8FF';
    clicksor_layer_ad_link_color = '#0000CC'; clicksor_layer_ad_text_color = '#000000';
    clicksor_text_link_bg = ''; clicksor_text_link_color = '#000FFF';
    clicksor_enable_pop = fa...
  7. Using The Image Editing Functions Of Php - Specifically, lines or regular polygons. (4)
    I've been experimenting a little with PHP's image functions and I was trying to see if I
    could make something that looked 3D, so I started with a cube because it's simple. To make an
    isometric picture of a cube, you need to start with a regular hexagon. However, making a regular
    hexagon isn't the easiest thing. Is there a function to create a regular polygon, or specify an
    angle and magnitude for a vector?...
  8. Mysql Edit - editing info in a MYSQL database (4)
    I have a simple database with a php form thats inserts the info into the database, and another file
    that extracts the info to display the info on another page.... Now my question is ......how do i
    add the EDIT button to edit the database??? here is my database CODE CREATE TABLE `businesses`
    (  `id` int(10) NOT NULL auto_increment,  `business` varchar(255) NOT NULL
    default '',  `description` text NOT NULL,  `emailaddress` varchar(255) NOT NULL
    default '',  `website` varchar(255) NOT NULL default '', ...
  9. Html Font Tags In Php - editing fonts using html? (11)
    I have a php script thats is fully written in php (no html at all). Now for my question, how can i
    edit the fonts? Ill make it easier to understand, the following is a data script (found the
    script): CODE <? $mese[0]="-"; $mese[1]="January";
    $mese[2]="February"; $mese[3]="March";
    $mese[4]="April"; $mese[5]="May";
    $mese[6]="June"; $mese[7]="July";
    $mese[8]="August"; $mese...
  10. Image/scrolling Menu Correlation - Help.... plz... (0)
    Hey Guyz... I'm working on re-designing my website, and I need a way to set-up my affiliates
    page. I have several (decent looking, not that it matters) images for my possible affiliates to
    choose from. I currently have this code in effect... CODE <html> <p
    align=center>Two different sized advertisments are currently available for ad-exchanges.
    Purchasing advertising is currently unavailable. Here are your ad-choices.<select multiple
    name="images" size=5><option>88x31 pixel box<option>120x240 pixel
    tower</select...
  11. Invision Power Board help - Editing Redirections.. (2)
    I put the login for the forums on the index of my site. (mysite.com/index.php) I want to be able to
    log on there, then have it go to another page of my site (mysite.com/members/index.php), and link
    the forums from that page, rather than it redirecting me straight to the forums. Anyone have an idea
    on how to accompolish this?...



Looking for editing, drop, menu, php

Searching Video's for editing, drop, menu, php
advertisement



Editing Drop Down Menu In Php



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE