Problème de requête
Posté : 29 août 2005, 14:43
Bonjour à tous
Voila ca fait plusieurs heures que je galère sur ce problème
je voudrais obtenir une moyenne des valeurs de la table TABLE_REVIEWS dans un site basé sur oscommerce et l'obtenir sous forme graphique
alors pour l'instant j'obtient un affichage aléatoire, le code fonctionne mais je veux une moyenne
normalement c'est du style SELECT products_id, AVG(reviews_rating) FROM reviews where products_id='idamettre' GROUP BY products_id;
mais je débute en php
merci pour votre aide
code:
Voila ca fait plusieurs heures que je galère sur ce problème
je voudrais obtenir une moyenne des valeurs de la table TABLE_REVIEWS dans un site basé sur oscommerce et l'obtenir sous forme graphique
alors pour l'instant j'obtient un affichage aléatoire, le code fonctionne mais je veux une moyenne
normalement c'est du style SELECT products_id, AVG(reviews_rating) FROM reviews where products_id='idamettre' GROUP BY products_id;
mais je débute en php
merci pour votre aide
code:
<?php
$random_select = "select p.products_id, r.reviews_rating from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";
if (isset($HTTP_GET_VARS['products_id'])) {
$random_select .= " and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'";
}
$random_product = tep_random_select($random_select);
$info_box_contents = array();
if ($random_product) {
$info_box_contents[] = array('text' => '' . tep_image(DIR_WS_IMAGES . 'stars_' . $random_product['reviews_rating'] . '.gif' , sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $random_product['reviews_rating'])) . '');
} elseif (isset($HTTP_GET_VARS['products_id'])) {;
}
new infoBox($info_box_contents, $column_location);
?>