tomburrows Posted May 10, 2008 Posted May 10, 2008 Hi I have included the average review stars image in product_info.php and would also like to include this in new_products.php. This is the code used in product_info.php: <?php $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); $reveiws_stars = $reviews_average['average_rating']; $reveiws_rating = number_format($reveiws_stars,0); if ($reviews['count'] > 0) { ?> <tr> <td class="main"><?php echo TEXT_REVIEW_AVERAGE; ?> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td> </tr> <tr> <td class="main"><?php echo tep_image(DIR_WS_IMAGES . 'stars_' . $reveiws_rating . '.gif'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } else { ?> <tr> <td class="main"><?php echo TEXT_REVIEW_NONE . ' ' . '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, tep_get_all_get_params()) . '">' . TEXT_REVIEW_INVITE . '</a>'; ?> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } ?> This code works great in product_info.php but doesn't work in the new_products.php module. Could some one tell me how I could change this code so it will work please. I have searched the forums but can't find any posts that solve my problem. I'm sure its not gonna be that much different to the original code but i'm quite new to PHP. Thanks :thumbsup:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.