PID YEAR NAME SP AC AG ST HA EN IN DI
Each PID will have multiple years associated with it. So for each PID there will be several rows of data in the table.
So I pull the data with a query like this;
$sql=" SELECT * FROM archive WHERE PID='$pid' ORDER BY YEAR DESC";
Okay so then I want to display the data in a table with a while loop that creates a new table row for every year listed and then displays each column in a table cell within that row.
I know how to do all that and it isn't a problem. I want to be able to color code specific changes in the data. For all the columns other than PID, NAME and YEAR I want it to show the change from one year to the next. So when I display the data year 2000 will be on top, 1999 under that and so on.
How would I go about telling it to look at the data and find the difference between the SP value for 2000 and the SP value for 1999? Then if the 2000 value is higher than the 1999 value change the font color to green, if it is lower change the font color to red.
Can this be done with an array of some sort or is there an easier way to accomplish this?
If you need to see the actual code for displaying the data I can whip it up real quick and post it if that will help. Basically thought I just wanted to make sure this sort of thing could be done before I went and coded the page that is going to call the data.
Thanks for the help!!