Sunday, January 23, 2011

Sunday 1/23/11


<?Php
echo "

Order processed.

";
echo "order processed at " . date('H:i, jS F Y');
echo "

";
// create short variable names
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
echo "

Your order is as follows:

";
echo $tireqty . " tires
";
echo $oilqty . " bottles of oil
";
echo $sparkqty . " spark plugs
";

$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo "

";

if ($totalqty == 0) {
echo '<p style="color:red">';
echo 'You did not order anything on the previous page!';
echo '

';
}

echo "Items ordered: " . $totalqty . "
";
$totalamount = 0.00;

define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);


$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;

echo "Subtotal: $" . number_format($totalamount, 2) . "
";

$taxrate = 0.10; // local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
echo "Total including tax: $" . number_format($totalamount, 2) . "
";

?>


Here is another tutorial

<?php
$distance = 50;
while ($distance <= 250) {
echo "<tr>";
echo $distance . "</td>";
echo "<td align = \"right\">" . ($distance/10) . "</td></tr>";
$distance += 50;
}
?>

1 comment:

Brad Jensen said...

The first php seesm to be the page that would be the target of a form's action, from the presene os POST variabless.

The second phpo is building the inside of a table, but without the beginning and ending < table > tags.

I can seee I need tor ead up some more on php.