so for school I have to make a comparison site for the products from MC and BK.
http://ift.tt/1JReCcA <- that's how far I am.
This is the code :
<html>
<head>
<link rel="stylesheet" type="text/css" href="style1.css" />
</head>
<?php
if(isset($_POST['formSubmit']))
{
$breakfastMC = $_POST['BreakfastMC'];
$breakfastBK = $_POST['BreakfastBK'];
if(empty($breakfastMC))
{
echo("<p>You didn't select any food.</p>\n");
}
else
{
$MC = count($breakfastMC);
echo("<p>You selected $MC: ");
for($i=0; $i < $MC; $i++)
{
echo($breakfastMC[$i] . " ");
}
}
if(empty($breakfastBK))
{
echo("<p>You didn't select any food.</p>\n");
}
else
{
$BK = count($breakfastBK);
echo("<p>You selected $BK door(s): ");
for($i=0; $i < $BK; $i++)
{
echo($breakfastBK[$i] . " ");
}
}
//$sumBK = array_sum($BK)
//$sumMC = array_sum($MC)
if ($sumBK = $sumMC){
echo 'equal';
}
function IsChecked($chkname,$value)
{
if(!empty($_POST[$chkname]))
{
foreach($_POST[$chkname] as $chkval)
{
if($chkval == $value)
{
return true;
}
}
}
return false;
}
}
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<div class="MC">
<h2><b>Mc Donalds</b></h2>
<br />
<b>Ontbijt:</b>
<br />
<input type="checkbox" name="BreakfastMC[]" value="2"> Croissant met jam en boter<br />
<input type="checkbox" name="BreakfastMC[]" value="3"> Pancakes met stroop <br />
<input type="checkbox" name="BreakfastMC[]" value="3"> McMuffin met Bacon en Ei <br />
<input type="checkbox" name="BreakfastMC[]" value="4"> McMuffin met Kaas <br /> <br />
<input type="checkbox" name="DrinksMC1" value="2"> 2x Versgemalen koffie <br />
<input type="checkbox" name="DrinksMC2" value="2"> 2x Thee <br />
<b>Lunch:</b>
<br />
<input type="checkbox" name="LunchMC1" value="LunchMD1"> Hamburger <br />
<input type="checkbox" name="LunchMC2" value="LunchMD2"> Cheeseburger <br />
<input type="checkbox" name="LunchMC3" value="LunchMD3"> 1955 met bacon <br />
<input type="checkbox" name="LunchMC4" value="LunchMD4"> McKroket <br /> <br />
<input type="checkbox" name="DrinksMC3" value="DrinksMD3"> Coca Cola Middel (0,4L) <br />
<input type="checkbox" name="DrinksMC4" value="DrinksMD4"> Coca Cola Groot (0,5L) <br />
<b>Avondeten:</b>
<br />
<input type="checkbox" name="DinerMC1" value="DinerMD1"> Big Mac <br />
<input type="checkbox" name="DinerMC2" value="DinerMD2"> Chicken Sensation <br />
<input type="checkbox" name="DinerMC3" value="DinerMD3"> Chili Chicken <br />
<input type="checkbox" name="DinerMC4" value="DinerMD4"> Big Tasty met bacon <br /> <br />
<input type="checkbox" name="DrinksMC5" value="DrinkeMD5"> Coca Cola Mega (0,7L) <br />
<input type="checkbox" name="DrinksMC6" value="DrinksMD6"> Coca Cola Groot (0,5L) <br />
<br />
</div>
<div class="BK">
<h2><b>Burger King </b></h2>
<b>Ontbijt:</b>
<br />
<input type="checkbox" name="BreakfastBK[]" value="3"> Mini Pancakes (9stuks) €1,50 364kcal<br />
<input type="checkbox" name="BreakfastBK[]" value="1.50"> Toastie €1,50 359 kcal<br />
<input type="checkbox" name="BreakfastBK[]" value="3.00"> Breakfast Burger €3,00 825 kcal <br />
<input type="checkbox" name="BreakfastBK[]" value="2.75"> Breakfast Wrap €2,75 441 kcal<br /> <br />
<input type="checkbox" name="DrinksBK1" value="3.80"> 2xKoffie €3,80 0 kcal<br />
<input type="checkbox" name="DrinksBK2" value="2.25"> 1 flesje Chaudfontaine (500 ml) €2,25 0 kcal<br />
<b>Lunch:</b>
<br />
<input type="checkbox" name="LunchBK1" value="4.55"> Grilled Chicken Wrap €4,55 344 kcal<br />
<input type="checkbox" name="LunchBK2" value="1.95"> Cheeseburger €1,95 338 kcal<br />
<input type="checkbox" name="LunchBK3" value="5.75"> Tripple Whopper €5,75 1114 kcal<br />
<input type="checkbox" name="LunchBK4" value="4.75"> Big King XXL €4,75 1022 kcal<br /> <br />
<input type="checkbox" name="DrinksBK3" value="2.00"> Coca Cola M (400 ml) €2,00 168 kcal<br />
<input type="checkbox" name="DrinksBK4" value="2.50"> Coca Cola XXL (750 ml) €2,50 315 kcal<br />
<b>Avondeten:</b>
<br />
<input type="checkbox" name="DinerBK1" value="DinerBK1"> Double Cheeseburger XXL €4,75 502 kcal <br />
<input type="checkbox" name="DinerBK2" value="DinerBK2"> Grilled Chicken BBQ €5,25 707 kcal<br />
<input type="checkbox" name="DinerBK3" value="DinerBK3"> Whopper Jr. €3,25 362 kcal <br />
<input type="checkbox" name="DinerBK4" value="DinerBK4"> Big King €3,75 552 kcal <br /> <br />
<input type="checkbox" name="DrinksBK5" value="DrinksBK5"> Coca Cola M (400 ml) €2,25 210 kcal <br />
<input type="checkbox" name="DrinksBK6" value="DrinksBK6"> Coca Cola XXL (750 ml) €2,50 315 kcal<br />
</div>
<div class="Button">
<input type="submit" name="formSubmit" value="submit">
</div>
</form>
</body>
</html>
Now what I want is to make a total sum of all the values checked within the area and then compare the pricedifference from the BK and the MC
this:
//$sumBK = array_sum($BK)
//$sumMC = array_sum($MC)
if ($sumBK = $sumMC){
echo 'equal';
Doesn't work so I am kinda clueless :(
Aucun commentaire:
Enregistrer un commentaire