I'm trying to make a form for a database that I have which is basically a 'top 25' poll for college basketball teams. Only about 25 people will take part in the vote, which will take place weekly. The idea being that on a page, there will be a pulldown menu where the user selects their name (no, it's not going to be the most secure, but that's ok) and then uses 25 pulldown menus to choose who they feel should be in that place. (ie, pulldown menu "1" would be who they think should be in first place....etc, etc to pulldown menu "25" would be who they think should be in last place)
And then when they submit it, it will insert into the database the info. I think I need some sort of loop or for each to make this work....
If I were doing this logically, I'd say I need to have a statement that says something like:
for each "position" (1 being the first pull down, 25 being the last) insert that position number (1-25) for the team chosen and apply it to the 'votername' chosen in the 'votername' pulldown menu. (I think, anyway).
My database has the following structure:
table-users:
userid, username
table-teams
teamid, teamname
table-votes
userid, teamid, position, timestamp
Now if I enter this information directly via the mysql terminal, the statement looks like this:
insert into votes
(userid, teamid, position) values
(1,5,1),
(1,10,2),
(1,2,3),
(1,7,4),
(1,6,5),
(1,9,6),
(1,1,7),
(1,3,8),
(1,4,9),
(1,8,10);
(I limited to 10 for this example)
I just don't know how to make turn this into an sql statement that works with a php form???