Well, for one thing "user" is a reserved word in MySQL, so that must be encased in back ticks. And there was a minor problem with my query. Here's a proper one:
SELECT id
FROM `user`
WHERE LEFT(`hphone`, 3) IN (216,234,283,330,419,440,513,567,614,740,937);
Then run that query and then do mysql_num_rows() on the result and it should work!!
$area_codes = array('216', '234', '283', '330', '419', '440', '513', '567', '614', '740', '937');
$query = "SELECT id
FROM `user`
WHERE LEFT(`hphone`, 3) IN (" . implode(',', $area_codes) . ")";
$result = mysql_query($query);
$num_of_rows = mysql_num_rows($result);
Alternatively you can just use MySQL's COUNT function in the query, and then the only result is the number of phone numbers:
SELECT COUNT(*) AS myCount
FROM `user`
WHERE LEFT(`hphone`, 3) IN (216,234,283,330,419,440,513,567,614,740,937)
Then, run the query, and either use [man]mysql_fetch_array[/man] or [man]mysql_result[/man] to get the only result, which will be the number Ohio phone numbers.
$area_codes = array('216', '234', '283', '330', '419', '440', '513', '567', '614', '740', '937');
$query = "SELECT COUNT(*) AS myCount
FROM `user`
WHERE LEFT(`hphone`, 3) IN (" . implode(',', $area_codes) . ")";
$result = mysql_query($query);
$num_users = mysql_result($result, 0, 'myCount');
Hope that helps!!