I have requested thought on my database design and processing ideas in this thread: viewtopic.php?p=82703
My website that this is going to go into is http://10secondclub.net
What I'm interested in reading here is what people think of my php logic.
soooo, on that note
The logic (or lack of)
Imagine I have a table called VOTING, it has these fields:
ID - UserID - EntryID - Rating - Month - Year
I also have a table called Entries where all the entries already reside, so each entry has these fields (amongst others):
ID - UserID - Rating - RatingAVG
1-Is user logged in?
2-If yes, then get their member id and stick it in $Uid
3-Parse thru the VOTING table where month is the same as the voting month AND year is the same as the voting year to see if the user has voted for this month.
4-If the user has NOT voted, then display the 1-5 rating box under each thumbnail
5-If the user HAS voted, then let them know they have voted under each thumbnail and what they voted (if they chose other than DO NOT VOTE. IE: 1, 2, 3, 4 or 5).
6-If user presses the vote button the voted for items get added to the database, the DO NOT VOTE items do not get added to database to save on space in database. These items are all added at ONE entry into the database per rating. So, if user 10 voted for 5 animations and gave them ratings it could look like this:
ID - UserID - EntryID - Rating - Month - Year
1 - 10 - 3 - 5 - 1 - 2004
2 - 10 - 7 - 3 - 1 - 2004
3 - 10 - 25 - 4 - 1 - 2004
4 - 10 - 31 - 5 - 1 - 2004
5 - 10 - 34 - 4 - 1 - 2004
At the end of the round, I use an admin panel to collate votes, and copy the ratings and create an average rating for each entry in the VOTING table that matches the month and year and copy them to the appropriate fields in the ENTRIES table. Another part of the code then displays this appropriately.
Now the code Logic (again, possible lack of
1- Is user logged in? (I already have code for this). If user is logged in I place their userid in a variable called $Uid.
2- Open database and table connections (for ENTRIES table), count full number of entries and stick it in a variable called $total.
3-Use variable $total to loop through a loop. In loop display thumbnails for each entry in the database that are to be voted on (we check if their month and year values are the same as the current round we are voting on).
4- Whilst displaying the thumbnails in this current loop we start another loop that searches through the VOTING table and checks if $Uid matches $UserID and therefore has already voted for the current item (EntryID).
5- If the user HAS voted for the item, then let them know they have voted under each thumbnail and print what they voted (if they chose other than DO NOT VOTE. IE: 1, 2, 3, 4 or 5).
6- If the user has NOT voted, then display the 1-5 rating box under each thumbnail so they can choose a rating.
7-Now the thumbnails are displayed on screen with little choice boxes under each one. If the user presses submit it then goes backstage to do the mojo
Mojo
ERM, I'm stuck.
I need a way to have, say, 40 items' worth of formdata sent to code that adds the info to the database. I described this at the start of this thread.
Also, one user may only vote for 3 items and another 15 items. How do I account for that?
I really appreciate anyone's thoughts on this. It's the most exciting and ambitious part of my site and I want to take my time to get it right. Any feedback anyone can give is going to be well recieved and I'll take it all and work through what you have to say.
Thanks again
Rob