devWhiz Posted April 22, 2011 Share Posted April 22, 2011 <?php function money($amount,$separator=true,$simple=false){ return (true===$separator? (false===$simple? number_format($amount,2,'.',','): str_replace('.00','',money($amount)) ): (false===$simple? number_format($amount,2,'.',''): str_replace('.00','',money($amount,false)) ) ); } $income = 5000000000; $daily = money($income*24,true,true); $weekly = money(($income*24)*7,true,true); $monthly = money((($income*24)*7)*30,true,true); ?> </center> <center> <table border="1"> <tr> <td>Daily</td> <td><?php echo $daily ?></td> </tr> <tr> <td>Weekly</td> <td><?php echo $weekly ?></td> </tr> <tr> <td>Monthly</td> <td><?php echo $monthly ?></td> </tr> </table> </form> </center> What am I doing wrong? Im fairly new to this Link to comment https://forums.phpfreaks.com/topic/234400-php-variable-in-html-table/ Share on other sites More sharing options...
mens Posted April 22, 2011 Share Posted April 22, 2011 The variables need an ending semi-colon(, or else it will show syntax errors. Link to comment https://forums.phpfreaks.com/topic/234400-php-variable-in-html-table/#findComment-1204709 Share on other sites More sharing options...
devWhiz Posted April 22, 2011 Author Share Posted April 22, 2011 oops didnt see that Lol Ok I put ; at the end of the variables as they should be and it is still not displaying the data in the table Link to comment https://forums.phpfreaks.com/topic/234400-php-variable-in-html-table/#findComment-1204710 Share on other sites More sharing options...
kansasakki Posted April 22, 2011 Share Posted April 22, 2011 <?php function money($amount,$separator=true,$simple=false){ return (true===$separator? (false===$simple? number_format($amount,2,'.',','): str_replace('.00','',money($amount)) ): (false===$simple? number_format($amount,2,'.',''): str_replace('.00','',money($amount,false)) ) ); } $income = 5000000000; $daily = money($income*24,true,true); $weekly = money(($income*24)*7,true,true); $monthly = money((($income*24)*7)*30,true,true); ?> <html> <center> <table border="1"> <tr> <td>Daily</td> <td><?php echo $daily; ?></td> </tr> <tr> <td>Weekly</td> <td><?php echo $weekly; ?></td> </tr> <tr> <td>Monthly</td> <td><?php echo $monthly; ?></td> </tr> </table> </form> </center> </html> The top php section did not end with ?> I also added the semicolons to the end of the variables in the php. I also added an <html> and </html> but no body or header tags. Kansas Link to comment https://forums.phpfreaks.com/topic/234400-php-variable-in-html-table/#findComment-1204712 Share on other sites More sharing options...
devWhiz Posted April 22, 2011 Author Share Posted April 22, 2011 Link to comment https://forums.phpfreaks.com/topic/234400-php-variable-in-html-table/#findComment-1204713 Share on other sites More sharing options...
mens Posted April 22, 2011 Share Posted April 22, 2011 Try without the money() function, as it is pointless anyway. <?php $income = 5000000000; $daily = number_format($income*24,0); $weekly = number_format(($income*24)*7,0); $monthly = number_format((($income*24)*7)*30,0); ?> <html> <center> <table border="1"> <tr> <td>Daily</td> <td><?php echo $daily; ?></td> </tr> <tr> <td>Weekly</td> <td><?php echo $weekly; ?></td> </tr> <tr> <td>Monthly</td> <td><?php echo $monthly; ?></td> </tr> </table> </form> </center> </html> Link to comment https://forums.phpfreaks.com/topic/234400-php-variable-in-html-table/#findComment-1204714 Share on other sites More sharing options...
devWhiz Posted April 22, 2011 Author Share Posted April 22, 2011 ahh my stupidity, I had it using html extension LOL Thanks guys Link to comment https://forums.phpfreaks.com/topic/234400-php-variable-in-html-table/#findComment-1204720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.