Voting form
Moderator: General Moderators
Voting form
Hello. I have a list of songs, all of them have a check box next to them. I also have a table for the votes. I want that if you check one or more songs and press submit, for the name of the song to be saved in the database. How can I do that? Thanks!
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Voting form
You probably need a song data table and and vote table. The song table would have and id, name, artist and whatever else you wanted. The vote table would save the song id for each vote.
I think in the form you can do something like this:
You would generate the checkboxes from your song data table.
The values will be in the $_POST['song'] superglobal when the form is posted. You would save those in the vote table.
I think in the form you can do something like this:
Code: Select all
<input type="checkbox" name="song[]" value="3" /> Some Song
<input type="checkbox" name="song[]" value="27" /> Another Song
<input type="checkbox" name="song[]" value="111" /> A Third SongThe values will be in the $_POST['song'] superglobal when the form is posted. You would save those in the vote table.
(#10850)