jcf Posted November 11, 2009 Share Posted November 11, 2009 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 .. Quote Link to comment https://forums.phpfreaks.com/topic/181090-solved-displaying-values-from-a-sql-count/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 11, 2009 Share Posted November 11, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/181090-solved-displaying-values-from-a-sql-count/#findComment-955510 Share on other sites More sharing options...
jcf Posted November 11, 2009 Author Share Posted November 11, 2009 OK thanks .. Quote Link to comment https://forums.phpfreaks.com/topic/181090-solved-displaying-values-from-a-sql-count/#findComment-955519 Share on other sites More sharing options...
FedEx11 Posted November 12, 2009 Share Posted November 12, 2009 Nope, I tryed this while ($row = mysql_fetch_assoc($count_wins)) { foreach($row as $data){ echo "<b>".$data."<br>"; } } this still gives me Resource id #4Resource id #52 Quote Link to comment https://forums.phpfreaks.com/topic/181090-solved-displaying-values-from-a-sql-count/#findComment-956434 Share on other sites More sharing options...
jcf Posted November 12, 2009 Author Share Posted November 12, 2009 Sorry ... FedEx11 is a diff accont i have .. seems to work now ... Quote Link to comment https://forums.phpfreaks.com/topic/181090-solved-displaying-values-from-a-sql-count/#findComment-956437 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.