HomieNick Posted March 12, 2007 Share Posted March 12, 2007 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 More sharing options...
Demonic Posted March 12, 2007 Share Posted March 12, 2007 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> <? } ?> Link to comment https://forums.phpfreaks.com/topic/42308-need-some-help-this-should-be-easy/#findComment-205234 Share on other sites More sharing options...
HomieNick Posted March 12, 2007 Author Share Posted March 12, 2007 i replaced the code with what you gave me and it just made the text so that I couldn't see it, it put it on one line but the text is now not visible. ??? :-\ Link to comment https://forums.phpfreaks.com/topic/42308-need-some-help-this-should-be-easy/#findComment-205246 Share on other sites More sharing options...
Demonic Posted March 12, 2007 Share Posted March 12, 2007 <?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 Link to comment https://forums.phpfreaks.com/topic/42308-need-some-help-this-should-be-easy/#findComment-205249 Share on other sites More sharing options...
HomieNick Posted March 12, 2007 Author Share Posted March 12, 2007 same thing happened :-\ Link to comment https://forums.phpfreaks.com/topic/42308-need-some-help-this-should-be-easy/#findComment-205252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.