Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-864053
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-867907
Share on other sites

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

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-867914
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/163757-mysql-dropdown-boxes/#findComment-867917
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.