Jump to content

Lisawynn

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Lisawynn's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you!! That worked great. I had tried using round but was putting it in the wrong place (newbie newbie newbie). I appreciate your assistance. Thanks so much!!!
  2. Hi. I have recently started learning PHP. I am playing with an invoice and I want the total to add up correctly. I have found that most of the time it does but some of the time, it does not. For example, I am working with 3 files (an html, css and php file - I have included the code for all three below) When you open the file Inv2.html and input "10" for Quantity and "23.61" for Unit Price (for example) and click the "calculate" button, the total of the invoice should be calculated. However, if you manually add up the numbers that appear in the text boxes (236.10, 16.53 and 16.53), the total should be 269.16 and not 269.15 as is displayed. I have tried using round but that rounds the total down to 269.00. Why is it not calculating based on 16.53+16.53+236.10? It is displaying 16.53 for the tax but is using the true number 16.527 for the calculation. Thanks for any assistance. border.css [code] td {     border-width: 1px;     border-style: solid;     border-color: #000000; } th {    border-width: 1px;     border-style: solid;     border-color: #000000; } [/code] Inv2.html [code] <html> <head> <title>Invoice</title> <link rel="stylesheet" type="text/css" href="border.css" /> </head> <body> <form method="post" action="Calc4.php"> <table border=0 width="100%">     <tr>         <th>Item</th>         <th>Catalogue#</th>         <th>Description</th>         <th>Quantity</th>         <th>Unit Price</th>         <th>Cost</th>     </tr>     <tr>         <td><input type="text" name="item" value="">         </td>         <td><input type="text" name="cat" value="">         </td>         <td>         <input type="text" name="desc" value="">         </td>         <td><input type="text" name="qty" value="">         </td>         <td><input type="text" name="price" value="">         </td>         <td><input type="text" name="cost" value="">         </td>     </tr> </table>     <input type="submit" value="calculate"> </form> </html> [/code] Calc4.php [code] <html> <head> <title>Invoice</title> <link rel="stylesheet" type="text/css" href="border.css" /> </head> <body> <form> <table border=0 width="100%">     <tr>         <th>Item</th>         <th>Catalogue#</th>         <th>Description</th>         <th>Quantity</th>         <th>Unit Price</th>         <th>Cost</th>     </tr>     <tr>         <td> <?print $item?></td>         <td> <?print $cat?></td>         <td> <?print $desc?></td>         <td> <?print $qty?></td>         <td> <?print $price?></td>         <td>$<?$cost=$qty*$price;         printf("%1\$.2f", round($cost, 2))?></td>     </tr>     <tr>         <td></td>         <td></td>         <td></td>         <td colspan="2">Subtotal</td>         <td>$<?printf("%1\$.2f",$qty*$price)?></td>     </tr>     <tr>         <td colspan="2"></td>         <td></td>         <td colspan="2">GST (7%)</td>         <td>$<?$GST=$cost*.07;         printf("%1\$.2f",$GST)?></td>     </tr>     <tr>         <td colspan="2"></td>         <td></td>         <td colspan="2">PST (7%)</td>         <td>$<?$PST=$cost*.07;         printf("%1\$.2f",$PST)?></td>     </tr>     <tr>         <td colspan="2"></td>         <td></td>         <td colspan="2">Total</td>         <td>$<?printf ("%1\$.2f",($cost+$GST+$PST))?></td> </table>     </form> </html> [/code] Thank you!!!
×
×
  • 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.