Page 1 of 1
Voting form
Posted: Tue Nov 24, 2009 8:18 pm
by xionhack
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!
Re: Voting form
Posted: Wed Nov 25, 2009 12:53 am
by Christopher
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:
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 Song
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.