I have a query that works fine, and I'd like to (if possible) in the same swipe add the total of the values of one column to the $result. In other words, I want to select * from the db and to the result, also add the sum of the values in a particular column. I have this:
...where $sort is populated according to whatever link was clicked...it's either blank or DESC...and woot! it works...Code:$query = "SELECT * FROM $myTable $sort";
...so the result is sorted, then list()ed into $result->fields... which I've then assigned to $stuff[] as such:
Is is possible to add up the values of $etc for all the rows returned and also include that value in the result? Or do I have to do another query separately to grab the sum of the values of a column? This would be the desired result:Code:for (; !$result->EOF; $result->MoveNext()) { list($this,$that,$etc) = $result->fields; $stuff[] = array('this'=> $this, 'that'=>$that, 'etc'=>$etc) } $result->Close(); return $stuff;
Hopefully this crazy idea is explained well enough... I think I'm going about it in the wrong way, but any assistance would be great!Code:$stuff[] = array( 'this'=>$this, 'that'=>$that, 'etc'=>$etc, 'TotalOfTheEtcColumn',$TotalOfTheEtcColumn );
Thanks,
Cranjled





Bookmarks