Help with MySQL results into columns

What I am looking to do is take a list of areas from a MySQL query within and display into multiple columns but with a maximum of 4 columns. Each column starts with unordered list (<ul>) and each item is the standard list item (<li>).

$arinfo = mysql_query("SELECT DISTINCT area FROM zipcodes WHERE marea='".$area_row['id']."' AND active='1' ORDER by area ASC");
$total = mysql_num_rows($arinfo);
$cols = ceil($total / 4);
$r = 0;

echo '<ul class="acol">';
while($col = mysql_fetch_assoc($arinfo)) {
  echo '<li>'.ucwords($col['area']).'</li>';
  if ($r == $cols) {
     echo '</ul><ul class="acol">';
echo '</ul>';

The problem with this method is for a big area with a lot of rows, I get only two columns. The first one is small and the second has the rest of the items but doesn’t break into a 3rd or 4th column.

You don’t reset $r when you start a new column. So the equation $r == $cols will be true only once.