it's easy
PHP Code:
$res = mysql_query("SELECT COUNT(*)...");
// mysql_fetch_array and mysql_fetch_assoc are slower and not important here
list($newcount) = mysql_fetch_row($res);
++$newcount; // increase the number
$file="count.txt";
if ($fh=fopen($file,"w+")) {
fwrite($fh,$newcount);
fclose($fh);
}