assign last field of a table to an input text

0

I have a table that stores the supplies of a vehicle and would like to make the following code work. I need to get the last record with the mileage of the odometer and already bring the specific input text, called kmPrevious. It has to be the last field, so I can find out the way. Example: kmExterior 115, kmAtual 215. Calculation (kmAtual - kmPrevious) = 100 km. So the current one I'm going to type, and I would like the previous one to automatically search the table (last recorded record). I'm doing it in a way that is not working:

<input type="text" name = "kmAnterior" placeholder = "KM Anterior" value = "<?php echo $linha['kmAbastecimento']; ?>">

Where this $linha is the form I'm using to fill a table (using while). I want to be able to always get the last value of the table and throw it directly in that field, in a clean and simple way, because the table has a series of other calculations.

    
asked by anonymous 28.07.2018 / 20:43

0 answers