I am having trouble getting my cost to populate on this page: Confirmation page
There are 3 different costs depending on how soon they want their document edited by:
- Standard - 3 Day/72 Hour Return - $5.00 Per Page
- Expedite - 2 Day/48 Hour Return - $7.50 Per Page
- Overnight - 1 Day/24 Hour Return - $9.00 Per Page
I wrote the code where it will calculate the cost for the Standard $5 option (although it won't show 2 decimal places). This is the number of pages ($numCount) multiplied by 5, but how do I automatically have it chose the correct code based on which option they chose? - Standard $5, Expedite $7.50, Overnight $9
CODE
<?php
$number = $numCount;
echo "\$" . $number*5;
$formatted = number_format($number, 2);
?>
$number = $numCount;
echo "\$" . $number*5;
$formatted = number_format($number, 2);
?>
Code for this page:
CODE
<?php
$words = $_GET['words'];
?>
<?php @$format= $_POST['serviceOption'];
if( is_array($serviceOption)){
while (list ($key, $val) = each ($serviceOption)) {
echo "$val <br>";
}
}//else{echo "not array";}
?></td>
</tr>
<tr>
<td class="pagetext"><strong>Word Count/Pages</strong><br />
(300 Words=1 Page)</td>
<td class="pagetext">
<?php
$txtWordCount = $_POST['txtWordCount'];
$numCount = $_POST['numCount'];
echo " ". $txtWordCount . " Words / " . $numCount . " Pages";
?>
</td>
</tr>
<tr>
<td class="pagetext"><b>Cost</b> </td>
<td class="pagetext">
<?php
$number = $numCount;
echo "\$" . $number*5;
$formatted = number_format($number, 2);
?>
</td>
</tr>
<tr>
<td class="pagetext"><b>Level Of Work</b> </td>
<td class="pagetext">
<?php @$format= $_POST['level'];
if( is_array($level)){
while (list ($key, $val) = each ($level)) {
echo "$val <br>";
}
}//else{echo "not array";}
?>
</td>
</tr>
<tr>
<td class="pagetext"><b>Writing Format</b> </td>
<td class="pagetext">
<?php @$format= $_POST['format'];
if( is_array($format)){
while (list ($key, $val) = each ($format)) {
echo "$val <br>";
}
}//else{echo "not array";}
?></td>
Code for previous page where selections are made Previous page where selections are made:
CODE
<?
$serv = $_GET['serv']; // retrieves the data and creates a variable called $serv
$words = $_GET['words']; // as above
$servvalue = $serv; // creating a value to go in the drop down box..
if($serv == 1)
{
$serv = "Standard - 3 Day/72 Hour Return - $5.00 Per Page";
$opt1 = ' selected="selected"';
}
if($serv == 2)
{
$serv = "Expedite - 2 Day/48 Hour Return - $7.50 Per Page";
$opt2 = ' selected="selected"';
}
if($serv == 3)
{
$serv = "Overnight - 1 Day/24 Hour Return - $9.00 Per Page";
$opt3 = ' selected="selected"';
}
?>
<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>
<!-- finish --> </td>
</tr>
<tr>
<td class="pagetext" width="145"><b>Word Count/Pages</b><br/>
(300 Words=1 Page) </td>
<td class="pagetext">
<!-- Word Count Below -->
<input name="txtWordCount" type="text" size="12" maxlength="12" value="
<?php echo $words; ?>" /></a>Words</a>
<input name="numCount" type="text" size="4" maxlength="4"
value="<?php echo ceil($words/300); ?>" /></a>Pages</a>
<br />
<a href="/cost.html">Word Counter/Cost Estimator</a> </td>
</tr>
<tr>
<td class="pagetext"><b>Level of Work</b> </td>
<td>
<select name='level[]'>
<option value='High School'>High School</option>
<option value='College - Admission'>College - Admission</option>
<option value='College - Under Graduate'>College - Under Graduate</option>
<option value='College - Post Graduate'>College - Post Graduate</option>
<option value='Website'>Website</option>
</select> </td>
</tr>
<tr>
<td class="pagetext"><b>Writing Format</b> </td>
<td><select name='format[]'>
<option value='MLA'>MLA</option>
<option value='AP'>AP</option>
<option value='N/A'>N/A</option>
</select> </td>
</tr>
<tr>
<td class="pagetext"><input type="submit" value="Proceed With Order" name="btnOrder" /></td></form>
