Jump to content

Drop down menu With priority


bumdeal2

Recommended Posts

Hey guys im looking to do a drop down menu which is pretty basic however, in this drop down menu it uses an array of 4 values eg Orange, Apples, Bananas, Strawberry's. For this menu if a user has previously chosen an Orange which is stored on the db then then when the drop down menu is loaded it should move Orange to the top of the list, the same applies for the other values. How could I do this? I know how to do the select statement and place the values in an array. from there I dont know quite how to approach it.

 

 

Thank you.

 

 

Link to comment
https://forums.phpfreaks.com/topic/245361-drop-down-menu-with-priority/
Share on other sites

I see what you mean however I do not want to create another table and call the db as I feel it would be inefficient and would be more beneficial to not call the db, however I want the script so that for instance as I said the value they chose is stored on the db, as well as the different fruits. what would be the best way to within the  drop down menu to automatically assign the value previously chosen by the user as the first option and then display the other options available for them to change. without repeating the option chosen by the user again.

 

I could do the menu like so;

 

if($fruit == "Orange"){

<select name="Fruit" value="options">

<option value="Orange">Orange</option>

<option value="Apple">Apple</option>

<option value="Straw">Strawberry</option>

 

else if($fruit =="Apple"){

<option value ="Apple">Apple</option>

<option value="Orange">Orange</option>

<option value="Strawberry">Strawberry</option>

....................................

 

 

But personally I think thats highly inefficient coding where I should be able to just have one menu with all the data organised to match the users options... If you get me.

 

Thanks again for your help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.