Here's how I am counting mysql rows in PHP:
// total Combining the results of the # and the main SQL statement $ $ sql = 'SELECT COUNT (*) for $ start and $ make from SEverschurch WHERE user_id = \' '. Mysql_real_escape_string ($ user_id). ' \ ';; $ Initial_query = mysql_query ($ sql) or die ("SQL error"); $ Num_sql = mysql_fetch_array ($ initial_query); $ Numrows = $ num_sql [0]; Mysql_free_result ($ initial_query);
Is there any more effective way to do this?
no If you want a count, you run a query that is already running.
If you need more efficiency, make sure there is an index on the user_id column
Comments
Post a Comment