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 Quote 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. Quote 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 Quote 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 Quote 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 Quote 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> Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.