Affiliate Marketing
Forum Search


Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 09-08-06
Wardy's Avatar
This is the one
 
Join Date: Aug 2003
Posts: 2,747
Thanks: 14
Thanked 0 Times in 0 Posts
Wardy is an unknown quantity at this point
  Pre selecting value from drop down menu with PHP/MYsql

I have another php/mysql problem if anyone is able to help (I have tried to make it as clear as posisble)

I have a drop down/list menu that I have entered a number of different options a user can choose from. When they select the one they want and submit it gets saved to the database. Now I know it's easy enough to pull the chosen selection out and display it on a page but what I want to do is the next time they enter their account area that the option they chose is to be pre-selected from the drop down list for them and this is the bit I'm struggling with.

Below is a sample drop down menu and to have a pre-selected answer you need to add "selected" after the value (as in the example under this one where Option 3 is pre-selected.)
Code:
<select name="favpr">
   <option value="option1">Option 1</option>
   <option value="option2">Option 2</option>
   <option value="option3">Option 3</option>
   <option value="option4">Option 4</option>
</select>
Code:
<select name="favpr">
   <option value="option1">Option 1</option>
   <option value="option2">Option 2</option>
   <option value="option3" selected>Option 3</option>
   <option value="option4">Option 4</option>
</select>
Can anyone help becuase I'm stumped at the moment.

Cheers
Wardy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-08-06
Registered User
 
Join Date: Aug 2005
Posts: 121
Thanks: 0
Thanked 1 Time in 1 Post
haggul is an unknown quantity at this point
If you are building the choices from a database or loop it's more simple - if not it's pretty easy just not very elegant :


<option value="option1" <?php if($varfromdb=="option1"){ echo " selected"; }?>>Option 1</option>

and so on
__________________
haggul
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-08-06
Northern Monkey's Avatar
Member
 
Join Date: Jan 2004
Location: UK
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Northern Monkey is an unknown quantity at this point
I agree with haggul, that's exactly how I do it. It doesn't look very clean but it works.

NM.
__________________
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
js/css/dhtml nice drop down menu? morleymouse Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 5 25-05-05 06:07 PM
Drop down menu jumping EyeOfTheTiger Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 2 22-03-05 05:58 PM
Drop Down Menu DaveR Organic Google Search Optimisation 6 10-03-04 12:16 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7