brown2005 Posted March 5, 2007 Share Posted March 5, 2007 Hi, I have the following while($years_array = mysql_fetch_array($years_query)) { $year = $years_array['year']; $year_rank = number_format($years_array['rank']); $year_change = number_format($years_array['change']); echo" <tr> <td width='50' align='center'><a href='' class='red'>$year</a></td> <td width='75' align='center'><a href='' class='red'>$year_rank</a></td> <td width='75' align='center'><a href='' class='red'>$year_change</a></td> </tr>"; at the moment the change is 0, but what I want is say i have the following 2006 1,000,000 0 2007 500,000 +500,000 what I want to do is be able to display the +500,000 if this ok cause that is the difference between 2006 and 2007, any help would be appreciated? thanks in advance. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 Is the +500,000 already in the table? Quote Link to comment Share on other sites More sharing options...
brown2005 Posted March 5, 2007 Author Share Posted March 5, 2007 no, thats what I was wondering if this could be done without putting it in the table Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 For 2 years it will be no prob but if it's going to be continuous you may want to do the calculation and insert it into the table before you display it. Reason is everytime another year is added you will have to add another calculation to the script. But if you do the calcultion and put it in the table, when you output you will only need to echo the info from the table. Understand? Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 5, 2007 Share Posted March 5, 2007 try this ok. <?php while($years_array = mysql_fetch_array($years_query)) { $year = $years_array['year']; $year_rank = number_format($years_array['rank']); $year_change = (number_format($years_array['change'])+(number_format($years_array['rank']))); echo" <tr> <td width='50' align='center'><a href='' class='red'>$year[/url]</td> <td width='75' align='center'><a href='' class='red'>$year_rank[/url]</td> <td width='75' align='center'><a href='' class='red'>$year_change[/url]</td> </tr>"; ?> Quote Link to comment Share on other sites More sharing options...
brown2005 Posted March 5, 2007 Author Share Posted March 5, 2007 sorry redarrow, i dont have this bit $year_change = number_format($years_array['change']); is there a way round this, as I would like it not to be stored in a table. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.