I must be doing something wrong, or I have something missing.
On the place on the form where I want the price to populate, how do I write it so it will only show the one price for the option selected?
If I put the below code, it does only show the one option price.
$cost = $numCount*5;
echo number_format($cost, 2);
I thought, "ok, it works for showing only the cost at $5 per page, I must need to just copy and paste that for each other price." That only ends up showing all 3 prices at once. How to I write it to take only the selected option? Here is the code I have (which I have incorrect):
<?php
$cost = $numCount*5;
echo number_format($cost, 2);
$cost = $numCount*7.5;
echo number_format($cost, 2);
$cost = $numCount*9;
echo number_format($cost, 2);
?>
I took the above advice and tried shortening my <select> statements. But when I did so, it placed that shortened up wording ("standard", "expedited" and "overnight") and displayed that shortened up wording on the next page (confirmation) rather than showing the full description of the option. I ended up changing it back.
Also, on the suggestion above, it had me change <select name='serviceOption[]'> to <select name="serviceOption">. When I do so, the selected option will not populate on the next page.
I guess just take a look at my code and see what you think. Thanks for the help!
Code on previous page http://www.grammarperfection.com/checkout.php?serv=2&words=241which creates the drop down list with the selections:
<form action="confirmorder.php" method="post">
<select name='serviceOption[]'>
<option value="Standard - 3 Day/72 Hour Return - $5.00 Per Page"<?php echo $opt1?>>Standard - 3 Day/72 Hour Return - $5.00 Per Page</option>
<option value="Expedite - 2 Day/48 Hour Return - $7.50 Per Page"<?php echo $opt2?>>Expedite - 2 Day/48 Hour Return - $7.50 Per Page</option>
<option value="Overnight - 1 Day/24 Hour Return - $9.00 Per Page"<?php echo $opt3?>>Overnight - 1 Day/24 Hour Return - $9.00 Per Page</option>
</select>
Code on page where this selection is supposed to show the selection madehttp://www.grammarperfection.com/confirmorder.php (note: this page will look incomplete unless you navigate to it from previous page), as well as calculating the price by multiplying number of pages ($numCount) by the price per page for each selection:
//part above HTML
<?php
$words = $_GET['words'];
switch ($_POST['serviceOption']) {
case 'Standard - 3 Day/72 Hour Return - $5.00 Per Page':
$perPage = 5;
break;
case 'Expedite - 2 Day/48 Hour Return - $7.50 Per Page':
$perPage = 7.5;
break;
case 'Overnight - 1 Day/24 Hour Return - $9.00 Per Page':
$perPage = 9;
break;
default:
echo 'ERROR: invalid service option';
}
?>
//code where it should populate the price
<?php
$cost = $numCount*5;
echo number_format($cost, 2);
$cost = $numCount*7.5;
echo number_format($cost, 2);
$cost = $numCount*9;
echo number_format($cost, 2);
?>