Jump to content

php variable in html table


devWhiz

Recommended Posts

<?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

<?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

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>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.