Nile
02-17-2008, 06:28 PM
Hey I posted this on another forum, but wanted to get a quick response, so here I go, :p.
I was looking throughout my php book yesterday, and found some little app, this was from my:
PHP For the world wide web, Larry Ullman,
the code is:
PHP Code:
<?php
if(isset($_POST['s'])){
$shipping = $_POST['shipping'];
$pay = $_POST['pay'];
$pr = $_POST['pr'];
$qa = $_POST['qa'];
$ds = $_POST['ds'];
$tx = $_POST['tx'];
$shipping = $_POST['shipping'];
$pay = $_POST['pay'];
$total = $pr * $qa + $shipping - $ds;
$taxrate = $tx/100 + 1;
$total = $taxrate * $total;
$monthly = $total / $pay;
$total = round($total, 2);
$monthly = round($monthly, 2);
print("You have selected to purchase:<br />
<b>$qa</b> widget(s) at <br /> $<b>$pr</b> price with a<br />
$<b>$shipping</b> shipping cost and a<br />
<b>$tx</b> percent tax rate.<br />
After your $<b>$ds</b> discount, the total cost $<b>$total</b>.<br />
Devided over <b>$pay</b> monthly payments, that would be $<b>$monthly</b> each.");
exit;
}
?>
Fill out the forums to calculate the costs: <br />
<form action="#" method="POST">
Price: <input type="text" name="pr" size="5" /><br />
Quantity: <input type="text" name="qa" size="5" /><br />
Discount: <input type="text" name="ds" size="5" /><br />
Tax: <input type="text" name="tx" size="5" /><br />
Shipping Method:
<select name="shipping">
<option value="5.00">Slow & Steady.</option>
<option value="8.00">Put a move on it.</option>
<option value="19.36">I need it yesterday!</option>
</select><br />
Number of payments: <input type="text" name="pay" size="3" /><br />
<input type="submit" name="s" value="Calculate" />
</form>
Now Ill take one line from that code:
that would be $<b>$monthly</b> each.
Now it says in my book:
You can use two methods to print a figure such as $200.00: put a space (or HTML tags, as you do here) between the $ sign and the variable name or escape the first dollar sign(print "\$$var".
You can't use $$variable because the combination of two $ signs creates a var thats to complicated to discuss in this book.
Now I tried the way that was "Two Complex", and it didn't make a diffrence at all, can anyone tell me what it means?
I was looking throughout my php book yesterday, and found some little app, this was from my:
PHP For the world wide web, Larry Ullman,
the code is:
PHP Code:
<?php
if(isset($_POST['s'])){
$shipping = $_POST['shipping'];
$pay = $_POST['pay'];
$pr = $_POST['pr'];
$qa = $_POST['qa'];
$ds = $_POST['ds'];
$tx = $_POST['tx'];
$shipping = $_POST['shipping'];
$pay = $_POST['pay'];
$total = $pr * $qa + $shipping - $ds;
$taxrate = $tx/100 + 1;
$total = $taxrate * $total;
$monthly = $total / $pay;
$total = round($total, 2);
$monthly = round($monthly, 2);
print("You have selected to purchase:<br />
<b>$qa</b> widget(s) at <br /> $<b>$pr</b> price with a<br />
$<b>$shipping</b> shipping cost and a<br />
<b>$tx</b> percent tax rate.<br />
After your $<b>$ds</b> discount, the total cost $<b>$total</b>.<br />
Devided over <b>$pay</b> monthly payments, that would be $<b>$monthly</b> each.");
exit;
}
?>
Fill out the forums to calculate the costs: <br />
<form action="#" method="POST">
Price: <input type="text" name="pr" size="5" /><br />
Quantity: <input type="text" name="qa" size="5" /><br />
Discount: <input type="text" name="ds" size="5" /><br />
Tax: <input type="text" name="tx" size="5" /><br />
Shipping Method:
<select name="shipping">
<option value="5.00">Slow & Steady.</option>
<option value="8.00">Put a move on it.</option>
<option value="19.36">I need it yesterday!</option>
</select><br />
Number of payments: <input type="text" name="pay" size="3" /><br />
<input type="submit" name="s" value="Calculate" />
</form>
Now Ill take one line from that code:
that would be $<b>$monthly</b> each.
Now it says in my book:
You can use two methods to print a figure such as $200.00: put a space (or HTML tags, as you do here) between the $ sign and the variable name or escape the first dollar sign(print "\$$var".
You can't use $$variable because the combination of two $ signs creates a var thats to complicated to discuss in this book.
Now I tried the way that was "Two Complex", and it didn't make a diffrence at all, can anyone tell me what it means?