[advanced search]
Results from the most recent live auction are here.
20 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-16-2006, 12:16 PM   · #1
Xyzer
Steven
 
Xyzer's Avatar
 
Name: Steven Gibbons
Location: United Kindom
Trader Rating: (45)
Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 (Donate)
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
Tsunami Relief AIDS/HIV
Rate My. . .

Hi,

I was wondering how i can make myself a script that put all the image in a database, then on the homepage it displays a random one, and people can rate it and it shows its rating.

What would it consist of and what would be some coding?

Cheers,
Steven


Please register or log-in into NamePros to hide ads
Xyzer is offline   Reply With Quote
Old 04-17-2006, 08:29 AM   · #2
Alar
NamePros Member
 
Trader Rating: (0)
Join Date: Mar 2006
Posts: 65
NP$: 33.05 (Donate)
Alar is an unknown quantity at this point
Easiest way to do it would be assigning to every picture an unique ID. Perhaps a growing number. Then all you have to do th get a random picture is get a random number from 1 to $number_of_pictures_you_have and pull 1 row from database with that specific images data (url, desc, previous ratings, size, etc)
__________________
Links to sites/domains I own or have made: 6x9.net * w98.net * caxap.org * huumor.com * fotoloto.com * ...
Alar is offline   Reply With Quote
Old 04-17-2006, 12:04 PM   · #3
Shorty
Senior Member
 
Shorty's Avatar
 
Name: Thomas White
Location: England
Trader Rating: (15)
Join Date: Sep 2005
Posts: 1,033
NP$: 31.15 (Donate)
Shorty is just really niceShorty is just really niceShorty is just really niceShorty is just really nice
Perhaps this will help:

Code:
<?php require_once ('connect.php'); $query = "SELECT ImageID FROM Images"; $result = @mysql_query ($query); $num = mysql_num_rows ($result); $id = rand(1,$num); // So basically you see how many records there are in the database, then generate a random number between 1 and that many records $query2 = "SELECT ImageID, Whatever, SomethingElse FROM Images WHERE ImageID='".$id."' "; $result2 = @mysql_query ($query2); ?>


Hope that was useful to you.
Shorty is offline   Reply With Quote
Old 04-17-2006, 12:18 PM   · #4
Peter
NamePros Staff
 
Peter's Avatar
 
Name: Peter
Location: Scotland
Trader Rating: (47)
Join Date: Nov 2003
Posts: 4,337
NP$: 2039.40 (Donate)
Peter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud of
Child Abuse Save The Children Save The Children
it is best not to upload images to the database, although databases can handle this type of data is not the best way to do it.

You could upload them into a folder and upload the filename of the image to the database then when selecting the image use the mysql RAND() function to select the image and put the url for the image into the img src tag when outputting.
Peter is offline   Reply With Quote
Old 04-17-2006, 12:23 PM   · #5
Xyzer
Steven
 
Xyzer's Avatar
 
Name: Steven Gibbons
Location: United Kindom
Trader Rating: (45)
Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 (Donate)
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
Tsunami Relief AIDS/HIV
how then would the rating system work for each image?
Xyzer is offline   Reply With Quote
Old 04-17-2006, 01:08 PM   · #6
Shorty
Senior Member
 
Shorty's Avatar
 
Name: Thomas White
Location: England
Trader Rating: (15)
Join Date: Sep 2005
Posts: 1,033
NP$: 31.15 (Donate)
Shorty is just really niceShorty is just really niceShorty is just really niceShorty is just really nice
Add 2 more fields: RatingTotal and RatingCount.

Use a <SELECT> box and make the selections 1-5 star, or whatever. Add this number to the RatingTotal, then add 1 to the RatingCount. The average would then obviously be RatingTotal / RatingCount.
Shorty is offline   Reply With Quote
Old 04-17-2006, 01:42 PM   · #7
Peter
NamePros Staff
 
Peter's Avatar
 
Name: Peter
Location: Scotland
Trader Rating: (47)
Join Date: Nov 2003
Posts: 4,337
NP$: 2039.40 (Donate)
Peter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud of
Child Abuse Save The Children Save The Children
or have another table that holds what people have rated the image along with the image id. Then to find the rating simply extract the sum of all the fields that are for that image and divide by the total amount of people who rated it.

Doing it this way would enable you to keep track of who has rated the images already (have another field with their username (if they have 1) or some other distinguishing mark such as an ip address (not fool proof but good enough for what you need). This would get around the majority of people who will try and up the rating of the image by continuously giving it a maximum rating.
Peter is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Proof is in the Parking Website Header Design Hunting Moon
Advertise your business at NamePros
All times are GMT -7. The time now is 09:46 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0