I want the query to retrieve topics but if the topic repeats I only want one result to show up, no duplicates. I also want it to return username and timestamp. Here is what i have now but I get an error. [mysql_fetch_array() expects parameter 1 to be resource]. Anybody have any ideas of how i should change this?
viewtopics.php
<?php
$sql="SELECT username, timestamp, topic FROM hotspots WHERE topic IN (Select MAX (id) FROM hotspots GROUP BY topic) ORDER BY id DESC";
$result=mysql_query($sql);
$color="1";
echo '<table width="472px" border="0" align="center" cellpadding="2" cellspacing="0" style="border:1px solid #0000ff;">';
while($rows=mysql_fetch_array($result)){
if($color==1){
echo "
<tr bgcolor='#6698FF' ><td style='border-top:1px solid #0000ff; color:#ffffff;font-weight: bold;'>".$rows['topic']."</td>
<td style='border-top:1px solid #0000ff; color:#ffffff;font-weight: bold;'>".$rows['username']."</td>
<td style='border-top:1px solid #0000ff; color:#ffffff;font-weight: bold;'>".$rows['timestamp']."</td></tr>";
$color="2";
} else {
echo "<tr bgcolor='#AFDCEC'>
<td style='border-top:1px solid #0000ff;color:#0000ff;font-weight: bold;'>".$rows['topic']."</td>
<td style='border-top:1px solid #0000ff;color:#0000ff;font-weight: bold;'>".$rows['username']."</td>
<td style='border-top:1px solid #0000ff;color:#0000ff;font-weight: bold;'>".$rows['timestamp']."</td></tr>";
$color="1";
}
}
echo '</table>';
?>