A Closer Look: Five MySQL functions that handle query results
Assigning variable names to a MySQL result set
After executing a query to select data from a MySQL table there are several functions you can use to perform operations on the retrieved data.
mysql_result() - fetches the contents of the specified cell
mysql_data_seek() - moves to the specified row of a result set
mysql_fetch_array() - fetches the next row in the result set as an array
mysql_fetch_object() - fetches the next row in the result set as an object
Count the number of MySQL Queries
How to count the number of MySQL queries used by your script
One way of optimizing your scripts that connect to MySQL databases is to determine how many queries to the database your script makes. If you would like to count the number of queries, you can write a script that will do so. You use this function in place of the regular mysql_query() function.
PHP Code:
<?php function cnt_mysql_query($sql=FALSE) { static $queries = 0; if (!$sql) return $queries; $queries ++; return mysql_query($sql); } $sql= "SELECT 8+9";