bumdeal2 Posted August 21, 2011 Share Posted August 21, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245361-drop-down-menu-with-priority/ Share on other sites More sharing options...
voip03 Posted August 21, 2011 Share Posted August 21, 2011 1.You need table call user selection, where you can store the user’s selection. 2.When the user clicks the drop down menu; query the user selection table 1st then query the selection table. 3.Display the list. Quote Link to comment https://forums.phpfreaks.com/topic/245361-drop-down-menu-with-priority/#findComment-1260207 Share on other sites More sharing options...
bumdeal2 Posted August 21, 2011 Author Share Posted August 21, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245361-drop-down-menu-with-priority/#findComment-1260235 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.