Forum Moderators: coopster
I want to post the order to the next .php page where the items will show on a final orderform with $price * $qty = $totalprice but want to send only the products where a quantity has been entered on the previous page.
I'm looking for code to include that will assist with that.
All responses appreciated.
thanks in advance.
Otherwise, you may need to use javascript on the first page to loop thru the form and send only the desired items.
<add>
To POST to the next page you'll need this on your form.
<form action="http://www.example.com/your_page.php" method="post">
Then on your_page.php you'll need to access the POST variables. Here's one method.
while(list($key, $value) = each($HTTP_POST_VARS))
{
if ($key == 'VAL1') {
$val1 = $value;
}
if ($key == 'VAL2') {
$val2 = $value;
}
The variables VAL1, VAL2, etc are the input variables on your form. The variables $val1, $val2, etc can be used in you php script.
</add>
The other problem (but if I can fix it your idea works fine) is that the qty fields that nothing was entered into all post to the next page as zero values - "0.00" and I haven't been able to just return a blank field. Any thoughts on that appreciated as well.
thanks.
<$php
if ($var1 == '0.00') {
$tempvar = ' ';
}
else {
$tempvar = $var1;
}
echo "$tempvar";
?>
And, Welcome to WebmasterWorld!
I'm calculating $qty * $price with this code:
<?php printf ("%01.2f", $_POST['Complete_Set']* $_POST['price_Complete_Set']);?>
is my problem with the printf variables?
I tried this and it works as well, but still renders the 0.00 instead of " "
<?php printf ("%01.2f", $tempvar * $_POST['price_Complete_Set']);?>
Thanks again,
mc
<?php
if ($var1 > 0) {
printf ("%01.2f", $var1 * $_POST['price_Complete_Set']);
}
else {
echo " ";
}
?>
Now, you really don't need $tempvar like I showed earlier, because you aren't changing it to a blank value for printing. At this point it just clutters things up... use the correct variable from your POST instead.
I'd like to exclude an HTML table row from being printed based on whether or not a quantity for that item has been entered. Something like this (but this doesn't work)
<? if ($var3 > 0) {echo
"<tr>
<td width=60><?php if ($var3 > 0) {printf ("%01.2f", $price3);}else {echo " ";}?></td>
<td WIDTH=40><?php if ($var3 > 0) {printf ("%01.2f", $var3 * $price3);}else {echo " ";}?> </td>
</tr>"
;}?>
Any suggestions there?
many thanks for your expertise and time.
mc
<?
if ($var3 > 0)
{
echo "<tr><td>";
printf ("%01.2f", $price3);
echo "</td><td>";
printf ("%01.2f", $var3 * $price3);
echo "</td></tr>";
}
?>
I know this is the PHP forum, but FYI... Ideally you should
- quote all attributes in HTML
- specify widths with CSS rather than HTML