reflash wrote:But now it only does the first category...
Why are you limiting the selection to return only the first result that you use $cat from? (Incidentally, if there is only one result, you certainly don't need to waste effort using a wholee loop to read it.)
Really, based on your description, though, you're setting yourself up for a lot of redundant database work. That will be slow.
$current_category = "";
$query = "Select cat, url, name from $table order by cat";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
if($current_category != $row['cat'])
{
// Print a category header line.
$current_category = $row['cat'];
}
// Print a url/name line.
}
So the category header line is only printed when the category changes. And of course you don't need to check when "the categories are not contiguous in the table" because databases are able to sort records.
EEEWWWW!!! <font> tags! If it's a header, use a header tag! That's what they're for!