Hey all,
I am using the 'star' rating system instead of the 9.5 numeric style.
What I am curious is this, is there an easy way to put an 'if/then' statement in here so that if the 'link' has less that '10' votes, it will show the 1st image, which I have set up as blank.
This way a site that has one vote of "10" does not get a 5 start rating.
I made horses for my 5 stars, since my site is a Ford Mustang site, if anyone desires those let me know.
Below is the code, just looking for an easy if then.
Thanks
Mike
sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like. It's a little complex looking just because we have to
# check for blank entries..
my (%rec) = @_;
my $rate_img = "";
$rate_00 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate00.gif" WIDTH=160 HEIGHT=16 ALT="Rate It!" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_01 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate01.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_02 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate02.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_03 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate03.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_04 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate04.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_05 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate05.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_06 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate06.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_07 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate07.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_08 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate08.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_09 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate09.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_10 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate10.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_11 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate11.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_12 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate12.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_13 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate13.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_14 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate14.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_15 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate15.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_16 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate16.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_17 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate17.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_18 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate18.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_19 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate19.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_20 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate20.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
if ($rec{'Rating'} eq '10.00') { $rate_img = $rate_20; }
elsif ($rec{'Rating'} eq '0') { $rate_img = $rate_00; }
elsif ($rec{'Rating'} le '0.50') { $rate_img = $rate_01; }
elsif ($rec{'Rating'} le '1.00') { $rate_img = $rate_02; }
elsif ($rec{'Rating'} le '1.50') { $rate_img = $rate_03; }
elsif ($rec{'Rating'} le '2.00') { $rate_img = $rate_04; }
elsif ($rec{'Rating'} le '2.50') { $rate_img = $rate_05; }
elsif ($rec{'Rating'} le '3.00') { $rate_img = $rate_06; }
elsif ($rec{'Rating'} le '3.50') { $rate_img = $rate_07; }
elsif ($rec{'Rating'} le '4.00') { $rate_img = $rate_08; }
elsif ($rec{'Rating'} le '4.50') { $rate_img = $rate_09; }
elsif ($rec{'Rating'} le '5.00') { $rate_img = $rate_10; }
elsif ($rec{'Rating'} le '5.50') { $rate_img = $rate_11; }
elsif ($rec{'Rating'} le '6.00') { $rate_img = $rate_12; }
elsif ($rec{'Rating'} le '6.50') { $rate_img = $rate_13; }
elsif ($rec{'Rating'} le '7.00') { $rate_img = $rate_14; }
elsif ($rec{'Rating'} le '7.50') { $rate_img = $rate_15; }
elsif ($rec{'Rating'} le '8.00') { $rate_img = $rate_16; }
elsif ($rec{'Rating'} le '8.50') { $rate_img = $rate_17; }
elsif ($rec{'Rating'} le '9.00') { $rate_img = $rate_18; }
elsif ($rec{'Rating'} le '9.50') { $rate_img = $rate_19; }
else { $rate_img = $rate_20; }
And then I call it with '$rate_img'.
I am using the 'star' rating system instead of the 9.5 numeric style.
What I am curious is this, is there an easy way to put an 'if/then' statement in here so that if the 'link' has less that '10' votes, it will show the 1st image, which I have set up as blank.
This way a site that has one vote of "10" does not get a 5 start rating.
I made horses for my 5 stars, since my site is a Ford Mustang site, if anyone desires those let me know.
Below is the code, just looking for an easy if then.
Thanks
Mike
Code:
sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like. It's a little complex looking just because we have to
# check for blank entries..
my (%rec) = @_;
my $rate_img = "";
$rate_00 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate00.gif" WIDTH=160 HEIGHT=16 ALT="Rate It!" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_01 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate01.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_02 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate02.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_03 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate03.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_04 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate04.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_05 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate05.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_06 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate06.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_07 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate07.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_08 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate08.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_09 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate09.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_10 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate10.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_11 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate11.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_12 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate12.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_13 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate13.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_14 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate14.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_15 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate15.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_16 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate16.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_17 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate17.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_18 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate18.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_19 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate19.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
$rate_20 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate20.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;
if ($rec{'Rating'} eq '10.00') { $rate_img = $rate_20; }
elsif ($rec{'Rating'} eq '0') { $rate_img = $rate_00; }
elsif ($rec{'Rating'} le '0.50') { $rate_img = $rate_01; }
elsif ($rec{'Rating'} le '1.00') { $rate_img = $rate_02; }
elsif ($rec{'Rating'} le '1.50') { $rate_img = $rate_03; }
elsif ($rec{'Rating'} le '2.00') { $rate_img = $rate_04; }
elsif ($rec{'Rating'} le '2.50') { $rate_img = $rate_05; }
elsif ($rec{'Rating'} le '3.00') { $rate_img = $rate_06; }
elsif ($rec{'Rating'} le '3.50') { $rate_img = $rate_07; }
elsif ($rec{'Rating'} le '4.00') { $rate_img = $rate_08; }
elsif ($rec{'Rating'} le '4.50') { $rate_img = $rate_09; }
elsif ($rec{'Rating'} le '5.00') { $rate_img = $rate_10; }
elsif ($rec{'Rating'} le '5.50') { $rate_img = $rate_11; }
elsif ($rec{'Rating'} le '6.00') { $rate_img = $rate_12; }
elsif ($rec{'Rating'} le '6.50') { $rate_img = $rate_13; }
elsif ($rec{'Rating'} le '7.00') { $rate_img = $rate_14; }
elsif ($rec{'Rating'} le '7.50') { $rate_img = $rate_15; }
elsif ($rec{'Rating'} le '8.00') { $rate_img = $rate_16; }
elsif ($rec{'Rating'} le '8.50') { $rate_img = $rate_17; }
elsif ($rec{'Rating'} le '9.00') { $rate_img = $rate_18; }
elsif ($rec{'Rating'} le '9.50') { $rate_img = $rate_19; }
else { $rate_img = $rate_20; }
And then I call it with '$rate_img'.