Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with averages


Going_Digital

Recommended Posts

Hi I have modified the product_info.php in MS2 trying to show the average star rating as part of the product info page. I'm almost there as I have the rating but it shows 4 decimal places. I just need to figure out how to return an integer so I can then proceed to the next step of drawing the stars.

 

reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");

   $reviews = tep_db_fetch_array($reviews_query);

$reviews_query_average = tep_db_query("select (avg(reviews_rating)) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");

   $reviews_average = tep_db_fetch_array($reviews_query_average);



   if ($reviews['count'] > 0) {

?>

     <tr>

       <td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?>

 Average Customer Rating <?php echo $reviews_average['average_rating'];?></td>

Link to comment
Share on other sites

  • 3 years later...

Archived

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

×
×
  • Create New...