Jump to content

Sum


user4fun
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...