[thelist] php/mySQL again - getting single result from query?

Anthony Baratta anthony at baratta.com
Fri Jun 11 19:54:14 CDT 2004


At 12:51 PM 6/11/2004, Tom Dell'Aringa wrote:

>$queryD = "select sum(teamAID) as gp
>     from games where teamAID = '$teamID'";
>
>$gamesResult = mysql_query($queryD);
>$losses = $gamesResult["gamesPlayed"]; <-- I think this is wrong??
>
>$losses doesn't hold any data... I'm not doing this right...

First off shouldn't that be $gamesResult["gp"], which is what you have in 
your SQL.

Second, don't forget this as a resource:

         http://www.php.net/manual/en/ref.mysql.php

I think you need to take $gamesResult and pass that through 
mysql_fetch_row() or mysql_fetch_array().

$rowDB = mysql_fetch_row($gamesResult);
$losses = $rowDB["gp"];

Or something like that - my PHP is very rusty.


---
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."



More information about the thelist mailing list