Jump to content

[SOLVED] Why wont this order?


iceblox

Recommended Posts

Hi Guys,

 

Thanks all for your help. I think i was trying to over complicate something that should have been so easy!

 

Im pretty much there but i need to chuck in a join as well, so far the query is this;

 

<?php

$result = $db->sql_query("SELECT rating_id, avg(rating_num) AS columnaverage FROM ratings GROUP BY rating_id ORDER BY columnaverage DESC");
                			while($row = $db->sql_fetchrow($result))
		{
                $format_number = number_format($row[columnaverage], 2, '.', '');
                echo "<br>$row[rating_id] <b>$format_number</b>";
}
?>

 

Normally i would join a table like this

 

$query = "SELECT * FROM ratings a, models b WHERE a.rating_id = b.modid GROUP BY rating_id";

 

but as i normally select * im not sure how i would go about this when im selecting certain data?

 

Is any one able to help me to get this done?

 

Thanks, Phil

Hi Keith,

 

Sorry i didnt give much detail! I needed to join my models table.

 

But i tried this;

 

<?php


   
        $result2 = $db->sql_query("SELECT rating_id, modname, manname, modid, avg(rating_num) AS columnaverage FROM ratings a, models b WHERE a.rating_id = b.modid GROUP BY rating_id ORDER BY columnaverage DESC");
                			while($row2 = $db->sql_fetchrow($result2))
		{
                $format_number = number_format($row2[columnaverage], 2, '.', '');
                echo "<br><a target=\"_blank\" href=\"$row2[manname]-$row2[modname]-Mobile-Review-$row2[modid].html\">$row2[manname] $row2[modname]</a> <b>$format_number</b>";


}
?>

 

And got it to work!!

 

Thanks for all your help again!

 

Thanks, Phil

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.