Click to See Complete Forum and Search --> : php help


monkeyboi
01-07-2006, 09:00 PM
hi,

$query= "select sum(amount) from sometable";
$result = mysql_query($query);

how do i get the result for the query above since the result from this query is a single value, but mysql_query($query) returns a resource to $result.

thx

monkeyboi
01-08-2006, 03:58 PM
hi,

$query= "select sum(amount) from sometable";
$result = mysql_query($query);

how do i get the result for the query above since the result from this query is a single value, but mysql_query($query) returns a resource to $result.

thx


come on ppl this is a simple question...please.........

cybertron
01-08-2006, 08:53 PM
I don't do MySQL and PHP, but this (http://us2.php.net/manual/en/function.mysql-fetch-object.php) looks like it might be what you're looking for.

serz
01-08-2006, 10:07 PM
You have to use mysql_result().

thaddaeus
01-09-2006, 12:23 AM
yep just do somthing like...


$newArray = mysql_fetch_array($result);
$username = $newArray['username'];


And the infamous php funtion list...PHP: Manual Quick Reference (http://www.php.net/quickref.php)...very usfull for simple things like this :)

Oh and be patient, Theres few people that have the time and know php or web design from what I've found on this site (not a diss to anyone), Most users script or code for linux not usually for web scripts.