kevin66 Posted May 18, 2011 Share Posted May 18, 2011 Hi, am trying without much luck, (I am new), to define an exchange rate on the page and then mutiplying it by a value I am extracting from a mysql db. I write the value as below normally but having trouble writing this entry and multiplying it by my defined exchanged rate of say 2.22. <?php if(!empty($row['Band_1_Price'])) {echo "<div class=pricing_box_right2>£".$row['Band_1_Price']."</div></div>"; } ?> Thanks so much. Link to comment https://forums.phpfreaks.com/topic/236741-define-exchange-rate-and-multiple-value-to-data/ Share on other sites More sharing options...
spiderwell Posted May 18, 2011 Share Posted May 18, 2011 what have you tried so far? ($row['Band_1_Price'] *2.22) Link to comment https://forums.phpfreaks.com/topic/236741-define-exchange-rate-and-multiple-value-to-data/#findComment-1216984 Share on other sites More sharing options...
kevin66 Posted May 18, 2011 Author Share Posted May 18, 2011 Exactly, but when I use it like - if(!empty($row['Band_1_Price'])) {echo "<div class=pricing_box_right2>£".$row['Band_1_Price']*2.22."</div></div>"; } it gives an error I think the prob is when I add the </div> Can I define it first and then use when i write as I need to write it in 6 places Link to comment https://forums.phpfreaks.com/topic/236741-define-exchange-rate-and-multiple-value-to-data/#findComment-1216991 Share on other sites More sharing options...
kevin66 Posted May 18, 2011 Author Share Posted May 18, 2011 I got it working like you said but it doesnt write 2 decimal places , how can i force it to do this? <?php if(!empty($row['Band_3_Price'])) {echo "<div class=pricing_box_right2>£".$row['Band_3_Price']*0.4."</div></div>"; } ?> Link to comment https://forums.phpfreaks.com/topic/236741-define-exchange-rate-and-multiple-value-to-data/#findComment-1216995 Share on other sites More sharing options...
spiderwell Posted May 18, 2011 Share Posted May 18, 2011 http://php.net/manual/en/function.number-format.php Link to comment https://forums.phpfreaks.com/topic/236741-define-exchange-rate-and-multiple-value-to-data/#findComment-1217192 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.