Jump to content

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


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.

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.