Connecting Tech Pros Worldwide Help | Site Map

compare data in php

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 28th, 2008, 07:57 AM
Familiar Sight
 
Join Date: Jan 2008
Posts: 142
Default 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?
Reply
  #2  
Old November 28th, 2008, 08:00 AM
nathj's Avatar
Expert
 
Join Date: May 2007
Location: North Tyneside
Posts: 852
Default

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
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.