Jump to content

need some help, this should be easy.


HomieNick

Recommended Posts

Maybe this is more html help, but I'm using a star rating system and I'm trying to figure out how to get the stars and the text on the line below it to be on the same line. ugh,

 

 

<?php
/*
Page:           _drawrating.php
Created:        Aug 2006
The function that draws the rating bar.	
--------------------------------------------------------- 
ryan masuga, masugadesign.com
[email protected] 
--------------------------------------------------------- */
function rating_bar($id,$units='') { 

require('_config-rating.php'); // get the db connection info

//set some variables
$ip = $_SERVER['REMOTE_ADDR'];
if (!$units) {$units = 10;}

$query=mysql_query("SELECT total_votes, total_value, used_ips FROM $tableName WHERE id='$id' ")or die(" Error: ".mysql_error());
$numbers=mysql_fetch_assoc($query);
$count=$numbers['total_votes']; //how many votes total
$current_rating=$numbers['total_value']; //total number of rating added together and stored
$tense=($count==1) ? "vote" : "votes"; //plural form votes/vote

// determine whether the user has voted, so we know how to draw the ul/li
$voted=mysql_num_rows(mysql_query("SELECT used_ips FROM $tableName WHERE used_ips LIKE '%".$ip."%' AND id='".$id."' ")); 

// now draw the rating bar
?>
<div class="ratingblock">

<div id="unit_long<?php echo $id ?>">
	<ul id="unit_ul<?php echo $id ?>" class="unit-rating" style="width:<?php echo $unitwidth*$units; ?>px;">
	<li class="current-rating" style="width:<?php echo @number_format($current_rating/$count,2)*$unitwidth; ?>px;">Currently <?php echo @number_format($current_rating/$count,2); ?>/<?php echo $units ?></li>
<?php
for ($ncount = 1; $ncount <= $units; $ncount++) { // loop from 1 to the number of units
	if(!$voted) { // if the user hasn't yet voted, draw the voting stars 
	?>
<li><a href="db.php?j=<?php echo $ncount ?>&q=<?php echo $id ?>&t=<?php echo $ip ?>&c=<?php echo $units ?>" title="<?php echo $ncount ?> out of <?php echo $units ?>" class="r<?php echo $ncount ?>-unit rater"><?php echo $ncount ?></a></li>
<?php
 } 
  }
$ncount=0; // resets the count
?>
	</ul>
	<p <?php if($voted){?> class="voted"<?php } ?>>Rating: <?php echo @number_format($current_rating/$count,1) ?> / <?php echo $units ?> (<?php echo $count ?> <?php echo $tense ?> cast)
</p>
</div>
</div>
<?
}
?>

 

I believe I have to replace the P, Ul, and Li, with other tags, don't I? I'm not sure how to do this.

 

if you would like to see the rating system for some reason, it's near the bottom of my testing page http://www.evadingshadows.com/indextest0001.php near the "quick summary" button.

 

THANKS!

Link to comment
https://forums.phpfreaks.com/topic/42308-need-some-help-this-should-be-easy/
Share on other sites

try this:

 

<?php
/*
Page:           _drawrating.php
Created:        Aug 2006
The function that draws the rating bar.	
--------------------------------------------------------- 
ryan masuga, masugadesign.com
[email protected] 
--------------------------------------------------------- */
function rating_bar($id,$units='') { 

require('_config-rating.php'); // get the db connection info

//set some variables
$ip = $_SERVER['REMOTE_ADDR'];
if (!$units) {$units = 10;}

$query=mysql_query("SELECT total_votes, total_value, used_ips FROM $tableName WHERE id='$id' ")or die(" Error: ".mysql_error());
$numbers=mysql_fetch_assoc($query);
$count=$numbers['total_votes']; //how many votes total
$current_rating=$numbers['total_value']; //total number of rating added together and stored
$tense=($count==1) ? "vote" : "votes"; //plural form votes/vote

// determine whether the user has voted, so we know how to draw the ul/li
$voted=mysql_num_rows(mysql_query("SELECT used_ips FROM $tableName WHERE used_ips LIKE '%".$ip."%' AND id='".$id."' ")); 

// now draw the rating bar
?>
<div class="ratingblock">

<div id="unit_long<?php echo $id ?>">
	<ul id="unit_ul<?php echo $id ?>" class="unit-rating" style="width:<?php echo $unitwidth*$units; ?>px;">
	<li class="current-rating" style="width:<?php echo @number_format($current_rating/$count,2)*$unitwidth; ?>px;">Currently <?php echo @number_format($current_rating/$count,2); ?>/<?php echo $units ?></li>
<?php
for ($ncount = 1; $ncount <= $units; $ncount++) { // loop from 1 to the number of units
	if(!$voted) { // if the user hasn't yet voted, draw the voting stars 
	?>
<li><a href="db.php?j=<?php echo $ncount ?>&q=<?php echo $id ?>&t=<?php echo $ip ?>&c=<?php echo $units ?>" title="<?php echo $ncount ?> out of <?php echo $units ?>" class="r<?php echo $ncount ?>-unit rater"><?php echo $ncount ?></a>
<?php
 } 
  }
$ncount=0; // resets the count
?><?php if($voted){?> <div class="voted"><?php } ?>Rating: <?php echo @number_format($current_rating/$count,1) ?> / <?php echo $units ?> (<?php echo $count ?> <?php echo $tense ?> cast)</div></li>
	</ul>
</div>
</div>
<?
}
?>

<?php
/*
Page:           _drawrating.php
Created:        Aug 2006
The function that draws the rating bar.	
--------------------------------------------------------- 
ryan masuga, masugadesign.com
[email protected] 
--------------------------------------------------------- */
function rating_bar($id,$units='') { 

require('_config-rating.php'); // get the db connection info

//set some variables
$ip = $_SERVER['REMOTE_ADDR'];
if (!$units) {$units = 10;}

$query=mysql_query("SELECT total_votes, total_value, used_ips FROM $tableName WHERE id='$id' ")or die(" Error: ".mysql_error());
$numbers=mysql_fetch_assoc($query);
$count=$numbers['total_votes']; //how many votes total
$current_rating=$numbers['total_value']; //total number of rating added together and stored
$tense=($count==1) ? "vote" : "votes"; //plural form votes/vote

// determine whether the user has voted, so we know how to draw the ul/li
$voted=mysql_num_rows(mysql_query("SELECT used_ips FROM $tableName WHERE used_ips LIKE '%".$ip."%' AND id='".$id."' ")); 

// now draw the rating bar
?>
<div class="ratingblock">

<div id="unit_long<?php echo $id ?>">
	<ul id="unit_ul<?php echo $id ?>" class="unit-rating" style="width:<?php echo $unitwidth*$units; ?>px;">
	<li class="current-rating" style="width:<?php echo @number_format($current_rating/$count,2)*$unitwidth; ?>px;">Currently <?php echo @number_format($current_rating/$count,2); ?>/<?php echo $units ?></li>
<?php
for ($ncount = 1; $ncount <= $units; $ncount++) { // loop from 1 to the number of units
	if(!$voted) { // if the user hasn't yet voted, draw the voting stars 
	?>
<li><a href="db.php?j=<?php echo $ncount ?>&q=<?php echo $id ?>&t=<?php echo $ip ?>&c=<?php echo $units ?>" title="<?php echo $ncount ?> out of <?php echo $units ?>" class="r<?php echo $ncount ?>-unit rater"><?php echo $ncount ?></a>
<?php
 } 
  }
$ncount=0; // resets the count
?><?php if($voted){?> <span class="voted"><?php } ?>Rating: <?php echo @number_format($current_rating/$count,1) ?> / <?php echo $units ?> (<?php echo $count ?> <?php echo $tense ?> cast)</span></li>
	</ul>
</div>
</div>
<?
}
?>

Try now

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.