Hi phpers!
I extract some values from a db as these:
2014 46
2013 57
2011 29
2010 89
Now, my goal is to calculate the percentage change in a year than the previous year in order to obtain this:
2014 46 -19%
2013 57 +96%
2011 29 -67%
2010 89
My code is actually;
$myquery = mysql_query("SELECT Year, Sales FROM Mytable");
while ($row = mysql_fetch_array($myquery)) {
echo $row['Year'] . ' ' . $row['Sales'];
}
Can you help me please? thanks