You need to CAST the count to a named variable...
Code:
$query="SELECT COUNT(*) AS numrows FROM $table_name";
$ret = mysql_query($query);
$fetched = mysql_fetch_array($ret);
echo 'Amount = '.$fetched['numrows'];
That's some really horrible code, btw.
...glad you got it sorted out.