Click to See Complete Forum and Search --> : How do I write code that keeps a log and updating info? PLEASEEEE HELP


porsche21
08-31-2007, 07:53 AM
I have a popup box that allows the user to submit the current amount of miles left on the vehicle after they are finished using that specific vehicle.

What I want is to be able to keep a log of the total miles and keep the miles updating after every use.

I have a table called trucks_miles with (4) fields called:
truck_id
start_miles
end_miles
truck_miles

How should I start my coding off to get this accomplished?:confused:

Markbad311
08-31-2007, 07:58 AM
$sql='UPDATE trucks_miles SET truck_miles = truck_miles + '.$newmiles.' WHERE truck_id = '.$id;

or you can insert a new row each time and SUM() the truck_miles field, where Truck_id = $id but then you will have to assign an auto incrementing ID field as and the Truck_id as the index.