<?php
if(isset($_POST['sub']))
{
$result = '';
switch($_POST['ysf'])
{
case '+': $result = $_POST['num1']+$_POST['num2'];break;
case '-': $result = $_POST['num1']-$_POST['num2'];break;
case '*': $result = $_POST['num1']*$_POST['num2'];break;
case '/': $result = $_POST['num1']/$_POST['num2'];break;
}
}
?>
<html>
<head>
</head>
<body>
<table align="center">
<form action="jsq.php" method="post" >
<caption>计算器</caption>
<tr>
<td>
<input type="text" name="num1" value="<?php echo $_POST['num1'] ?>">
</td>
<td>
<select name="ysf">
<option <?php if($_POST['ysf']== '+') echo 'selected' ?> value="+">+<option>
<option <?php if($_POST['ysf']== '-') echo 'selected' ?> value="-">-<option>
<option <?php if($_POST['ysf']== '*') echo 'selected' ?> value="*">*<option>
<option <?php if($_POST['ysf']== '/') echo 'selected' ?> value="/">/<option>
</select>
</td>
<td>
<input type="text" name="num2" value="<?php echo $_POST['num2'] ?>">
</td>
<td>
<input type="submit" name="sub" value="计算">
</td>
<td>
<label><?php echo $result ?></label>
</td>
</tr>
</form>
</table>
</body>
</html>