Ok I changed the code into following,
now in the table I get 3 values (instead of 4 values)..anyway the values returned are all three the same which should be impossible.
There's also an error in the while loops of result3 and 4.
Invalid Resource and Invalid use of group function.
What am I doing wrong???
$query = "SELECT address,max(rate) as '$rate' FROM statistiek group by address";
$result = mysql_query($query);
echo mysql_error();
while ($row = mysql_fetch_array($result)){
$rate = $row['rate'];
$address = $row['address'];
echo "<table border=\"1\" width=\"100%\"><tr><th>Highest rate</th><th>Average</th><th>Bad Sites</th><th>Good sites</th></tr>";
}
$query2 = "SELECT address as 'Site Location',avg(rate) as '$rate2' FROM statistiek group by address";
$result2 = mysql_query($query2);
echo mysql_error();
while ($row = mysql_fetch_array($result2)){
$rate2 = $row['rate2'];
$address = $row['address'];
echo "<td><a href=\"{$row['address']}\">{$row['address']} Rate:{$row['rate2']}</a></td>";
}
$query3 = "SELECT address as 'Site Location',avg(rate) as '$rate3' FROM statistiek WHERE avg(rate)<6 group by address";
$result3 = mysql_query($query3);
echo mysql_error();
while ($row = mysql_fetch_array($result3)){
$rate3 = $row['rate3'];
$address = $row['address'];
echo "<td><a href=\"{$row['address']}\">{$row['address']} Rate:{$row['rate3']}</a></td>";
}
$query4 = "SELECT address as 'Site Location',avg(rate) as rate4 FROM statistiek WHERE avg(rate)>6 group by address";
$result4 = mysql_query($query4);
echo mysql_error();
while ($row = mysql_fetch_array($result4)){
$rate4 = $row['rate4'];
$address = $row['address'];
echo "<td><a href=\"{$row['address']}\">{$row['address']} Rate:{$row['rate4']}</a></td></tr></table>";
}