Jump to content

Sum


user4fun

Recommended Posts

$result is a resource. It points to data, but isn't data itself. So it can't be echoed or iterated through like an array.The function described here is one way of getting the data $result points to. Look at the example. Notice how the function is used in a loop to extract data from multiple rows. (A loop is not necessary when you can guarantee that only one row will be returned, or when you only want one row at a time.)http://www.php.net/manual/en/function.mysql-fetch-assoc.php

Link to comment
Share on other sites

You can use the SQL 'AS' operator to assign the result to an element:

$query = "SELECT SUM(Ad_Max_Pts) AS addition FROM tblAd WHERE FK_BusID ='$ses_ID'";$result = mysql_query($query) or die(mysql_error());$res = mysql_fetch_assoc($result);echo $res['addition'];

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...