I would like to know if this is the best way to mix HTML and PHP for getting the results of from a checkbox list. Is there a better way to present the data?
After the check for array_key_exists(), I believe I would check to see if it is false to stop the code from executing anything more.
<?php
if(array_key_exists('submit',$_POST)){
}
?>
```html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#total
{
background-color:#FFFFCC;
border:thin #000000 solid;
width:500px;
}
</style>
</head>
<body>
<div id="total">
<?php
echo '';
echo '';
foreach($_POST['price'] as $value){
echo '';
echo '';
echo '';
$grandTotal= $total + $grandTotal;
}
echo 'You have picked the following programs: |
---|
';
switch($value){
case "summer":
echo "$134.00 for 20 hours of tutoring per month";
echo ' '; echo "Your subject is ".$_POST['subject']; $total = 134.00; break; case "person": echo "Live in Person tutoring - $40.00 per hour"; $total = 40.00; break; case "online": echo "Live Online Tutoring - $12.00 per hour"; $total = 12.00; break; case "five_hours": echo "$37.00 a week for 5 hours"; $total = 37.00; break; case "two_days": echo "$22.00 a week for 2 days per week - 2 hours of tutoring per week"; $total = 22.00; break; case "three_days": echo "$30.00 a week for 3 days per week - 3 hours of tutoring per week"; $total = 30.00; break; default: echo "no selection"; } echo ' |
'; setlocale(LC_MONETARY, "en_US"); echo money_format("The price is %i", $grandTotal); ?>
</div>
</body>
</html>