Forum Moderators: coopster
in hidden form input?
<?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99 ";}?>
it calculates shipping costs and I have to pass the result on to the next pages...
this doesn't work, of course, but you get the idea...:
<input type="hidden" value="<?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99 ";}?>" ">
thanks a million. This forum is excellent.
mc
Another way to do it could be like this:
<?php
if($total > 81.75){
$value = printf ("%01.2f", $total * .11);}
else{
$value = "8.99 ";
}
?>
<input type="hidden" name="somename" value="<?php echo $value;?>" />
-sned
<edit>
added the somename thing
</edit>
I can't see where this portion of the code would be giving a parsing error, except for the "printf" part here. Use printf when you want to output the data, use sprintf [php.net] if you want to format and assign the value to a variable.