Problème de requête

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Problème de requête

par storm61 » 29 août 2005, 17:45

j'ai épurer le code mais toujours pas de soluce

Ya pas quelqu'un qui a une idée? :lol:

<?php echo TEXT_REVIEW_RATING ; ?>
<?php
$sort = "select products_id, reviews_rating from " . TABLE_REVIEWS ;
if (isset($HTTP_GET_VARS['products_id']));
//SELECT products_id, AVG(reviews_rating) FROM reviews where products_id='idamettre' GROUP BY products_id;

$result = tep_random_select($sort);

$info_box_contents = array();
if ($result) {

$info_box_contents[] = array('text' => '' . tep_image(DIR_WS_IMAGES . 'stars_' . $result['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);
?>

Problème de requête

par storm61 » 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 :D

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);
?>