Hi
There are some problems with the solution you're offering here.
If you make those changes - the table data will be updated, and re-votes WILL be allowed.... BUT
1. for the picture, number of votes will continue to increase - even if re-votes are done.
This is wrong, especially since the rating is calculated as division by num_votes + 1 every time.
2. Also, a summary of ratings is kept, and each re-vote is added to that sum.
So in real, the REPLACE you're doing there is not effective: because the rating keeps growing and growing.
(even through the votes table contains the correct number of votes...)
So what you will see is two things:
a. your number of votes per pic will keep growing with each re-vote
b. Your vote average will go 'crazy' with some wierd number which is not an average of nothing really...
To make this problem more 'spicy', you cannot mod the vote summary, because you'd need to first substract the prev vote, and then add the new re-vote and then redo the avg. but you cannot - since you don't know the old vote value (!)
If you'd like to implement this correctly, I can suggest this:
1. Change the votes table to have another column - which is the vote value for each vote.
2. remove the columns for 'number of votes', and 'pic rating' from the pics table!. You don't need those!
3. use SQL commands COUNT() and AVG() functions to get data about pic rating!
-> have SQL do all the 'dirty' work for you for calculations. All the wierd calcs you're doing in ratepic.php are not needed.
Just store the data in SQL, and when you SELECT it back do a nested SELECT to get the AVG and COUNT per picture.
I hope this is helpful,
Dan
PS - I'm working with code in CGP 1.4.13