MySQL Forums
Forum List  »  PHP

Re: AVG Displays Null
Posted by: Liam
Date: February 18, 2006 09:22AM

Thanks.

I've tried that, and it prints fine as SQL (As I can see my using phpmyadmin). However, when I go to echo it it still orders it by default (art_ID). Here is my code:

<?php
$i=1;
$ii=1;
$select = "select art_ID, art_Name, art_Url, art_Price, FORMAT(AVG(vot_Score), 2), artvot_ID from art, voting where artvot_ID = art_ID group by art_ID order by 'FORMAT( AVG( vot_Score ) , 2 )' DESC;";
$result = mysql_query($select, $ServerConnect);
while($r=mysql_fetch_array($result) and($i<11)){
$score=$r["FORMAT(AVG(vot_Score), 2)"];
$name=$r["art_Name"];
$id=$r["art_ID"];
$price=$r["art_Price"];
echo "$ii. <a href =\"art.php?id=$id\">$name</a> - £$price.00 - $score<br>";
$i=$i+1;
$ii=$ii+1;}
?>

Basically it should collect the first 10 results (which it does fine), and order it by rating (top first - which it doesn't!)

Thanks again.

Options: ReplyQuote


Subject
Written By
Posted
February 17, 2006 03:52PM
February 17, 2006 05:34PM
February 17, 2006 05:43PM
February 18, 2006 03:37AM
February 18, 2006 09:06AM
Re: AVG Displays Null
February 18, 2006 09:22AM
February 18, 2006 10:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.