Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 25-11-2011, 09:47 PM   #1 (permalink)
Apprentice
 
Join Date: Jul 2009
Posts: 62
Default need to substract data current row-previous row in php


Quote:
while ($db_fields = pg_fetch_assoc($results)) {
if(date("Y-m-d")==$db_fields['dt'])
{
break;
}else
{
print "<tr><td>" . $db_fields['dt'] . "</td>";
print "<td>" . $db_fields['count'] . "</td></tr>";
}
}
as you can see in the sample code the loop gives me data somewhat like this

Date Count
2011-1-1 200
2011-1-2 250
2011-1-3 300
2011-1-4 150

now i want to insert a code in the while loop so that i get a custom 3rd column with output something like this


Date Count Diff
2011-1-1 200
2011-1-2 250 50
2011-1-3 310 60
2011-1-4 150 -150

kindly someone help me with the logic behind it
all coding is being done in php
abhijeet2021 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:36 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2