我有一个硬件问题,要求我计算超过 2 美元的汤的数量,如果有人要输入它们。我的教授暗示我应该使用递增来计算超过 2 美元的汤的数量。我的 PHP 代码如下。我对 PHP 很陌生,我的教授在给出例子、指导和做老师方面都很差。任何帮助都会很棒!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Cafe</title>
<style type="text/css" media="screen"> .error { color: red; } </style>
</head>
<body>
<?php
$monday = $_POST['monday'];
$tuesday = $_POST['tuesday'];
$wednesday = $_POST['wednesday'];
$thursday = $_POST['thursday'];
$friday = $_POST['friday'];
$monday_item = $_POST['monday_item'];
$tuesday_item = $_POST['tuesday_item'];
$wednesday_item = $_POST['wednesday_item'];
$thursday_item = $_POST['thursday_item'];
$friday_item = $_POST['friday_item'];
$m_price = $_POST['m_price'];
$t_price = $_POST['t_price'];
$w_price = $_POST['w_price'];
$th_price = $_POST['th_price'];
$f_price = $_POST['f_price'];
$total = ($m_price + $t_price + $w_price + $th_price + $f_price);
if( empty ($_POST['tuesday']))
{print '<p class="error"> You did not complete all of the required fields</p>';
$okay = FALSE;
}
if ( !is_numeric ($_POST['th_price']))
{print '<p class="error"> That is not a number </p>';
$okay = FALSE;
}
if ($_POST['m_price'] > 10)
{print '<p class="error"> That is too Much!!! </p>';
}
if($total > 10):
echo "total is greater than 10";
elseif($total == $b): // Note the combination of the words.
echo "total equals 10";
else:
echo "total is less than 10";
endif;
if ($_POST['m_price'] > 2)
{print }
print
"<table border='1'>";
print "<tr>
<td> $monday </td>
<td> $monday_item </td>
<td> $m_price </td>
</tr>
<tr>
<td> $tuesday </td>
<td> $tuesday_item </td>
<td> $t_price </td>
</tr>
<tr>
<td> $wednesday </td>
<td> $wednesday_item </td>
<td> $w_price </td>
</tr>
<tr>
<td> $thursday </td>
<td> $thursday_item</td>
<td> $th_price </td>
</tr>
<tr>
<td> $friday </td>
<td> $friday_item </td>
<td> $f_price </td>
</tr>";
print "</table>";
print "<p> Your total price of soups is $total </p>";
?>
</body>
</html>