Jump to content

Calculation of two fields with results in another


brosskgm

Recommended Posts

I have a small database that keeps track is miles for each day worked and the code was written for me. The mileage fields are all edit box fields.

 

What I would like to do is to put a calculate button to to subtract the start miles from the end miles and put the result in total_miles_driven edit box.

 

I've look at http://us.php.net/manual/en/function.array-sum.php

 

But can't seem to grasp subtraction.

 

I've tried

 

($mileage_stop - $mileage_start) = array('total_miles_driven');

 

But doesn't seem to work. Not understanding enough about calculations in php

I'm at a loss.

 

Thanks

 

else if(SUBDIR == 'mileage') {
   $fields[] = array('name' => 'work_date', 'type' => 'date', 'len' => 15);
   $fields[] = array('name' => 'project', 'type' => 'varchar', 'len' => 50);
   $fields[] = array('name' => 'mileage_start', 'type' => 'varchar', 'len' => 15);
   $fields[] = array('name' => 'mileage_stop', 'type' => 'varchar', 'len' => 15);
   $fields[] = array('name' => 'total_miles_driven', 'type' => 'varchar', 'len' => 15);
   $fields[] = array('name' => 'notes', 'type' => 'text', 'len' => 100);
   
   // When this var is set, will enable date selection for the given fields
   $date_selection_fields = array('work_date');
  
   $totals_fields = array('total_miles_driven');

 

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.