How can I do this in a better way?
$query = mysql_query("SELECT * FROM table WHERE region='example1'");
$num_rows_example1 = mysql_num_rows($query);
$query = mysql_query("SELECT * FROM table WHERE region='example2'");
$num_rows_example2 = mysql_num_rows($query);
$query = mysql_query("SELECT * FROM table WHERE region='example3'");
$num_rows_example3 = mysql_num_rows($query);
Maybe with an Array and Foreach?
Thanks!
mysql_*functions. They're being deprecated. Instead use PDO (supported as of PHP 5.1) or mysqli (supported as of PHP 4.1). If you're not sure which one to use, read this SO article.