My final code works great. Thanks for your help. In case anyone else is searching for the same thing here is what worked for me:
<?
if (!($result = mysql_db_query("$DB","select r_id, catref, filename, linkname, description, active from report where catref=5 and active=1"))) {
DisplayErrMsg(sprintf("internal error %d:%s\n",
mysql_errno(), mysql_error()));
return 0 ;
}
echo"<table border=1 cellspacing=1 cellpadding=1>";
$count=1;
$sql="...";
$num_results=mysql_num_rows($result);
for($i=0; $i<$num_results; $i++){
$row = mysql_fetch_array($result);
if($count==1){
echo"<tr>";
echo"<td>".$row['linkname']."</td>";
}
if($count==2){
//echo"<tr>";
echo"<td>".$row['linkname']."</td>";
}
if($count==3){
//echo"<tr>";
echo"<td>".$row['linkname']."</td>";
echo"</tr>";
$count=0;
}
$count++;
}
?>
</table>