Connecting Tech Pros Worldwide Help | Site Map

compare data in php

  #1  
Old November 28th, 2008, 08:57 AM
Familiar Sight
 
Join Date: Jan 2008
Posts: 194
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?
  #2  
Old November 28th, 2008, 09:00 AM
nathj's Avatar
Expert
 
Join Date: May 2007
Location: North Tyneside
Posts: 853

re: compare data in php


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call value in different programs in PHP cheryl answers 1 January 23rd, 2007 12:04 PM
php extensions and windows... specifically extension_dir Chris Paul answers 3 December 5th, 2005 12:45 AM
Cannot use mail() in IE, only works in a debugger--help baustin75@gmail.com answers 8 October 5th, 2005 06:15 PM
how does PHP5 process POST data in creating $_POST array? billy.becker@gmail.com answers 14 July 17th, 2005 02:07 PM