![]() |
![]() |
#3 (permalink) |
Junkie
Location: RI
|
Shouldn't be that hard to create...
basically I think you'd want to create a table in a DB and have the table have three fields, ID, img location, rating. Have a function generate a random number and have that run against the table, pull that ID, and pull the image location and send it to your field. Probably not the best solution but that's what I can see from here after looking at it for a minute. |
![]() |
![]() |
#4 (permalink) |
paranoid
Location: The Netherlands
|
In addition to the above suggestion, to create correct ratings, your DB will need at least another field: number_of_votes.
The field 'rating' should contain the sum of all votes received. The average is then easily calculated: PHP Code:
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) Last edited by Silvy; 07-14-2004 at 04:41 AM.. |
![]() |
![]() |
#5 (permalink) |
Junkie
Location: RI
|
Herm, what about this for a table
PHP Code:
When the voter sees the pic/story/etc, they vote on it, it gets added to the current rating then divide it by two. If you wanted to record the complete total, you'd need to probably make an array which would probably get kinda ugly. If you want to keep track of all of the votes that someone does, then you'll need to create a login. When the person views a pic, and then rates it, have a seperate table such as: PHP Code:
|
![]() |
![]() |
#6 (permalink) | |
paranoid
Location: The Netherlands
|
Quote:
I'd say store the total awarded points (the sum of all votes) in the 'rating' column and the total number of votes in the 'num_votes' column. When a user votes, add the value to 'rating', and add 1 to 'num_votes'. The average vote is then 'rating' / 'num_votes'. This way there is no need for an array... (don't know how you figured that?) If you want one vote per user (and thus a login type system) use the second, more elegant, solution by Fallon
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
|
![]() |
![]() |
#7 (permalink) | |
Junkie
Location: RI
|
Quote:
It all depends on what you want to do I believe. You could use the system as a rating for user writing/drawing/photo/etc. In that type of environment, I'd personally want the way I had it because I'd want to be able to ban people =p |
|
![]() |
![]() |
#8 (permalink) | |
paranoid
Location: The Netherlands
|
Quote:
Though for the last point you could probably use cookies...
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
|
![]() |
Tags |
free, php, rate, script |
|
|