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');

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.