compare data in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    compare data in php

    I' developing web application using php and mysql. In there every half an hour data receive and stored in the data base.
    ex: 6:00am 2.3
    6.30am 2.8
    7:00am 3.0
    Now i want to take the difference between current value and previous value and store. How can I do that?
  • nathj
    Recognized Expert Contributor
    • May 2007
    • 937

    #2
    It's difficult to tell with so little information but could you issue some SQL order by the unique ID DESC to give the records in reverse order then limit the output to 2 records. This would give you the 2 most recent records. Then you could calculate the difference and store it back tot he table.

    That assumes you have an auto incremented unique ID - fairly standard so the process should work for you.

    Cheers
    nathj

    Comment

    Working...