Re: FN-FORUM: Image upload and rating site
date posted 27th April 2008 10:23
Paul Young wrote:
> Hello everyone,
>
> Just wondered if you could help me out.
>
> I've just been asked if I could have a look at doing a site that people
> would upload their images to and then other users would rate them.
>
> It's not a boy/girl, hot or not type of site as it's peoples own artwork
> that they'll be uploading.
>
> Does anyone know of a pre-built script that I could use as a basis to start
> on.
>
> Any suggestions would be really gratefully received.
>
> Paul Young.
>
>
>
>
Actually, this kind of thing is pretty easy - you might want to just
write your own, rather than using anything else.
The bits you really need are (obviously) the image upload and rating
parts. Will it be only signed-in users that can rate? Or is it
"World+Dog" ?
Upload is easy - you're taking the file, adding it to a file structure
(there's endless tutorials about that on t'internet already if you
haven't done it before) and adding data to a database table about the
image. (For example, image_id, image_name, image_description,
image_uploaded_by )
For the ratings, you have a rating out of 10. When the rating is
selected, it's added to a database table, along with the image_id, the
user_id of the person rating the image (assuming it's only registered
users doing the rating, otherwise you'll be wanting to store something
like the IP address) and the date/time of the rating. (That way, if
someone re-rates the image, the re-rating either overwrites the previous
one, or is ignored, depending on your client's preference - in the case
of unregistered users, you're probably going to want to block/update a
re-rate from the same IP address within twenty or thirty minutes, I
would estimate)
When the image displays, you need to query the rating table for all
ratings with the id of image_id, then average them out to get the rating
to display. That's one query, and maybe some server-side maths (I can't
offhand remember if MySQL will do the average score easily in the query)
Ta-da, pretty much all you need. I know I could knock that up in about
24 hours max - including testing.
Hope that helps.
Alex
http://www.ozbon.com