<?php $query = mysql_query("SELECT COUNT(`id`) AS total FROM `table`") or die(mysql_error()); $r = mysql_fetch_array($query); echo $r['total']; ?>