Hi,
I wonder if you can help. I run a site with numerous external links and I'm trying to display the highest rated links.
I've got the links to display fine, but I cant seem to get it to display the highest rated ones.
All help appreciated, please tell me what I've done wrong.
Heres my code;
function top_links() {
$query = "SELECT * FROM links ORDER BY '$average_vote' LIMIT 20";
$result = mysql_query($query) or die ('Error: listing links');
$rows = mysql_fetch_array($result);
while ( $rows = mysql_fetch_array($result) ) {
$prog_id = $rows['prog_id'];
$link_id = $rows['link_id'];
$link_type = $rows['link_type'];
$link_title = $rows['link_title'];
$link_url = $rows['link_url'];
$link_num_votes= $rows['link_num_votes'];
$link_rating = $rows['link_rating'];
$link_status = $rows['link_status'];
if ($link_num_votes >= 1) {
$average_vote = $link_rating / $link_num_votes;
$average_vote = number_format($average_vote, 2);
echo ("$link_title - $link_num_votes - $average_vote <br>");
}
elseif ($link_num_votes == 0) { echo("");}
}
}