This topic is locked

Using max() instead of average or count

11/7/2006 10:44:26 PM
PHPRunner General questions
D
darkmage0 author

Hey I was wondering if there is a way to use max() to find the max value in a colume instead of average,sum or count. Im making a contorl panel for a company that filters water and have a colume with PH readings ranging from 1 to 10. there is a PH reading every 5 min's and i need to pull the PH record that is the hight value between two datetime ranges or the hight and the lowest PH reading every day for a month. if any one know of a way to do this it would be godsent i have been looking at the phprunner genarated code for about 8 hours and im new to php so any help would be very helpful

J
Jane 11/8/2006

Hi,
you can do the following:

  1. select Total option for your column on the Fields order and totals tab.
  2. Edit label of Total on the Visual editor tab (replace Total label with Max) and build your pages.
  3. open generated ..._list.php file, find this line:
    if(is_numeric($data["FieldName"])) $totals["FieldName"]+=$data["FieldName"];



and replace it with this one:

if(is_numeric($data["FieldName"]))

if ($totals["FieldName"]<$data["FieldName"]) $totals["FieldName"]=$data["FieldName"];



where FieldName is your actual field name.

D
darkmage0 author 11/14/2006

hey
thanks that worked out great for the max. i was wondering if i wanted to do a min instead of a max can i just flip the code or is there some thing else that i have to change
thank you

Sergey Kornilov admin 11/14/2006

Use > instead of <. This is it.

D
darkmage0 author 11/17/2006

Hey
I changed out the < with > but it does not work all i get is 0.00. i tried it out on alot of different search's and still just 0.00 do i have to change a variable around.
thank you

J
Jane 11/20/2006

Hi,
to do min instead of max open ..._list.php file, find following lines:

$data=db_fetch_array($rs);

while($data && $recno<=$PageSize)



and replace it with this one:

$data=db_fetch_array($rs);

$totals["FieldName"]=$data["FieldName"];

while($data && $recno<=$PageSize)



Also don't forget to change < with >.