View Single Post
  #6 (permalink)  
Old 05-09-2008, 12:34 AM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming God
 
Join Date: Feb 2008
Posts: 742
Last Blog:
Programming "Just a ...
Rep Power: 8
phpforfun will become famous soon enoughphpforfun will become famous soon enough
Default Re: help on a php 5 star rating system

Hum, it seems so, I guess looking at the other code just complicated it...

here is what I did.

Update Times Rated
PHP Code:
        $result mysql_query("SELECT * FROM webmasters WHERE id='$hostid'");
        
$get mysql_fetch_array($result);
        
$totalrates $get['totalrates'];
        
$newtotalrates $totalrates $rated;
        
$query  "UPDATE `webmasters` SET `totalrates`='$newtotalrates' WHERE `id`='$hostid'";
        
mysql_query($query) or die('Error in query: '.$query.' :<br /><br /> 'mysql_error()); 

Echo The Stars
PHP Code:
$ratingpoints $totalrates $count;
if (
$ratingpoints <= 0  ){$rater_stars "./images/00star.gif";$rater_stars_txt="Not Rated";}
if (
$ratingpoints >= 0.5){$rater_stars "./images/05star.gif";$rater_stars_txt="0.5";}
if (
$ratingpoints >= 1  ){$rater_stars "./images/1star.gif";$rater_stars_txt="1";}
if (
$ratingpoints >= 1.5){$rater_stars "./images/15star.gif";$rater_stars_txt="1.5";}
if (
$ratingpoints >= 2  ){$rater_stars "./images/2star.gif";$rater_stars_txt="2";}
if (
$ratingpoints >= 2.5){$rater_stars "./images/25star.gif";$rater_stars_txt="2.5";}
if (
$ratingpoints >= 3  ){$rater_stars "./images/3star.gif";$rater_stars_txt="3";}
if (
$ratingpoints >= 3.5){$rater_stars "./images/35star.gif";$rater_stars_txt="3.5";}
if (
$ratingpoints >= 4  ){$rater_stars "./images/4star.gif";$rater_stars_txt="4";}
if (
$ratingpoints >= 4.5){$rater_stars "./images/45star.gif";$rater_stars_txt="4.5";}
if (
$ratingpoints >= 5  ){$rater_stars "./images/5star.gif";$rater_stars_txt="5";}
Echo 
'<img src="'.$rater_stars.'?x='.uniqid((double)microtime()*1000000,1).'" />'?> 
__________________
Free Proxy || Reliable Hosting
Reply With Quote