Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
blith
Client



Joined: Jul 18, 2003
Posts: 977

PostPosted: Fri May 21, 2004 2:27 pm Reply with quote

I have 7.2 and I am not sure if this is the case in all versions but when you submit a review it ask for a rating from 1-10 but then when it posts said review it translates your rating into stars. 1 gives half a star and two gives a full star, 3 a star and a half so and so on. What I would like to know is there a way to modify this so that you either get 10 stars or give a rating from 1-5 which then translates into stars? Thanks.
Here is the code:
Code:
function display_score($score) {

    $image = "<img src=\"images/blue.gif\" alt=\"\">";
    $halfimage = "<img src=\"images/bluehalf.gif\" alt=\"\">";
    $full = "<img src=\"images/star.gif\" alt=\"\">";

    if ($score == 10) {
   for ($i=0; $i < 5; $i++)
       echo "$full";
    } else if ($score % 2) {
   $score -= 1;
   $score /= 2;
   for ($i=0; $i < $score; $i++)
       echo "$image";
       echo "$halfimage";
    } else {
   $score /= 2;
   for ($i=0; $i < $score; $i++)
       echo "$image";
}

I am looking at it and it makes a little sense but if anyone can help I would appreciate it.
 
View user's profile Send private message Visit poster's website
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Fri May 21, 2004 5:47 pm Reply with quote

I don't follow you exactly either you want to do away with the half stars is the idea?
So a rating of 5 = 5 stars and a rating of 10 =10 stars?

try this should work no promises so backup?
Code:


function display_score($score) {
    $image = "<img src=\"images/blue.gif\" alt=\"\">";
    $halfimage = "<img src=\"images/bluehalf.gif\" alt=\"\">";
    $full = "<img src=\"images/star.gif\" alt=\"\">";

    if ($score == 10) {
   for ($i=0; $i < 10; $i++)
       echo "$full";
    } else if ($score % 2) {
        $score = $score;
//   $score -= 1;
//   $score /= 2;
   for ($i=0; $i < $score; $i++)
       echo "$image";
    //   echo "$halfimage";
    } else {
//   $score /= 2;
   for ($i=0; $i < $score; $i++)
       echo "$image";
    }
}
 
View user's profile Send private message
blith







PostPosted: Sat May 22, 2004 4:56 pm Reply with quote

That worked great! But how can I just have a 1-5 scale and 1 star for each point? Rated 1 gives 1 star rated 2 gives 2 stars all the way to five...
 
sixonetonoffun







PostPosted: Sat May 22, 2004 5:16 pm Reply with quote

Just remove the 6-10 options from the form. Change the 10's to 5's in the function display_score. Should be good to go then I'd think.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©