user4fun Posted September 26, 2009 Share Posted September 26, 2009 $query = "SELECT SUM(Ad_Max_Pts) FROM tblAd WHERE FK_BusID ='$ses_ID'"; $result = mysql_query($query) or die(mysql_error()); How do i show the result of the $query statment??echo ----------??Thank you Link to comment Share on other sites More sharing options...
jeffman Posted September 26, 2009 Share Posted September 26, 2009 $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 More sharing options...
Ingolme Posted September 26, 2009 Share Posted September 26, 2009 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 More sharing options...
jeffman Posted September 26, 2009 Share Posted September 26, 2009 Ah. That's what I get for not looking at the whole question. Link to comment Share on other sites More sharing options...
user4fun Posted September 27, 2009 Author Share Posted September 27, 2009 Perfect, thank you for much for the help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.