Consider this SQL query
$sql = "select count(*) as count from table where value='this'";
This query is going to return only one value in the field count.
Is there a way to get that value without using a fetch_array and pointing the first value of the returned array instead?
mysql_result()will allow you to pull the value directly from the result set without having to use a fetch method. Here’s a very simple example of how you can use it to get your single value:There are three parameters for the
mysql_result()function; first is the result set itself, second is the row index and third is the field index. I’m only using the first two parameters since the third one will default to 0, the first field returned.