Hooker Posted June 26, 2009 Share Posted June 26, 2009 I was just wondering if anyone could tell me how to do this: - Have a normal HTML dropdown box like this: January Febuary March April etc but when the page loads, it grabs a value from a table and selects that value in the dropdown box, so say someone previously selected "March" and now they've gone back to the form to change it to January, march will already be selected. Thanks for any and all help in advance! Quote Link to comment https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/ Share on other sites More sharing options...
soycharliente Posted June 26, 2009 Share Posted June 26, 2009 This forum is for helping people work through problems that they have already previously started and couldn't finish. If you're looking for someone to write code for you, there is a separate forum for that. If you do have some code that is currently not working and you like us to look at it, feel free to post it. Quote Link to comment https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-864053 Share on other sites More sharing options...
Hooker Posted July 2, 2009 Author Share Posted July 2, 2009 Actualy its the "PHP Help" forum and i had a legitimate question about how to do something in PHP/MySQL after searching online for a while, trying to find a method to do it. I wasn't asking for anyone to do it for me, if thats how you took it then i'm sorry it wasn't worded so that you could understand it but it was never my intention to get readymade code. If you didn't want to help/were unable to help, fine, just don't reply. Quote Link to comment https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-867907 Share on other sites More sharing options...
Zane Posted July 2, 2009 Share Posted July 2, 2009 Unless you have a user membership system setup...then you'd need a table for visits/selections In the table you would have - their ip - their month choice (using a number) .....that's pretty much it. Then in your dropdown box creation... you'd search the table by the current users IP and take the month choice.. if it's 0 then they haven't chosen anything....or if their IP isn't found else .... echo the word selected in your while loop Quote Link to comment https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-867914 Share on other sites More sharing options...
soycharliente Posted July 2, 2009 Share Posted July 2, 2009 Never said I didn't want to help, was just pointing out that if you post code, you might be more likely to get some help. You want the month that has been previously selected to be unique for each user? Maybe you could just use a MySQL database table that stores it. I would use the user's id from the user table as a reference and just store the text of what month they chose. Whenever they choose a month, take the user that's logged in, get their id, and update the choice table. I would probably lay it out like this: users ---------- id username password etc... month_choice ---------- user_id choice Then once you've got users and data rolling, they might look like this: users ---------- 1 admin password etc... 2 jsmith password etc... 3 bthompson password etc... month_choice ---------- 1 January 2 March 3 December Then just query and grab the month they last had selected. Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-867917 Share on other sites More sharing options...
Hooker Posted July 2, 2009 Author Share Posted July 2, 2009 sorry about my initial reply, so freaking hot at the moment x.x thanks for the help, i think its got me in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-867926 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.