Jump to content

[SOLVED] Displaying values from a SQL count...


jcf

Recommended Posts

Hi,

Easy enough question i just forget the exact method ..

I have ...

 

//count wins ...
$count_wins = mysql_query("SELECT count(*) FROM `matches` 
WHERE result = 'W'
AND Player1_ID = $player1_val
AND Player2_ID = $player2_val ");

 

 

Then i want to display this :

echo "<h2><b> Wins ". $count_wins . "</h2></b>" ;

 

But what is displayed is  Wins Resource ID # 3

 

(or similar...)

 

How to i convert this php variable to a normal int?

 

becuase i didn't need to do this before in another query when i used to compare values ..

 

 

 

 

A SELECT query that executes without any errors returns a result resource -

 

Return Values

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning result set, mysql_query() returns a resource on success, or FALSE on error.

 

You must then fetch a row from the result set (there will be only a single row for your query with the count(*) statement) using either a mysql_fetch_xxxxx instruction or a mysql_result() instruction.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.