简单的计算代码 [英] Simple calculation code

查看:55
本文介绍了简单的计算代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到该代码的哪一部分是错误的.选择提交"按钮后,浏览器应显示日期,否.项,累计的总金额和其他详细信息,但在表单中显示其余的代码.谁能帮我吗?

I can''t seem to find which part of this code is wrong. After selecting "submit" button the browser should display the date, no. of items, total amount accumulated and other details but instead along the form it displays the rest of the code. Can anyone help me?

<<pre lang="xml">?
$htmltag="<html>
<body>
<form method=''post'' action=''activity.php''>
<table>
<tr>
<td bgcolor=''gray''>Item</td>
<td bgcolor=''gray''>Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td><input type=''text'' name=''value1''></td>
</tr>
<tr>
<td>Oil</td>
<td><input type=''text'' name=''value2''></td>
</tr>
<tr>
<td>Spark Plugs</td>
<td><input type=''text'' name=''value3''></td>
</tr>
<tr>
<th colspan=2><input type=''submit'' value=''SUBMIT ORDER'' name=''submit1''>
<select name=''menu''>
        <option selected>I''m A Regular Customer</option>
        <option>TV Advertising</option>
        <option>Phone Directory</option>
        <option>Word of Mouth</option>
    </select>
</th>
</tr>
</table>
</form>
</body>
</html>";
if ($_POST[''submit1''])
{
echo "<font size=''12'' font face = ''Arial''>BOBS AUTO PARTS</font>";
echo "<br><font size=''10'' font face = ''Arial''>Order Results</font>";
echo "<br><br>";
echo "<br><font face = ''Arial''>Order Processed at ";
echo "<br><br>";
$tire = $_POST[''value1''];
$oil = $_POST[''value2''];
$spark = $_POST[''value3''];
$itemsum = $tire+$oil+$spark;
echo "<br><font face = ''Arial''>".$tire." tire";
echo "<br><font face = ''Arial''>".$oil." oil";
echo "<br><font face = ''Arial''>".$spark." spark plugs";
$prodtire = $tire*2;
$prodoil = $oil*4;
$prodspark = $spark*6;
$prodsum = $prodtire+$prodoil+$prodspark;
$deduction = $prodsum*0.10;
$total = $prodsum-$deduction;
$date1=time();
echo "<br><font face = ''Arial''>Your Order is as follows: ".$date1;
echo "<br><font face = ''Arial''>Items Ordered  ".$itemsum;
echo "<br><font face = ''Arial''>Sub Total: $".$prodsum;
echo "<br><font face = ''Arial''>Total: $".$total;
$combobox1 = $_POST[''menu''];
echo "<br><br>".$combobox1;
} else
{
echo $htmltag;
}
?


>


>

推荐答案

htmltag =< html> <身体> < form method =''post''action =''activity.php''> < table> < tr> < td bgcolor =''灰色''>项目</td> < td bgcolor =''灰色''>数量</td> </tr> < tr> < td>轮胎< td> < td><输入类型=文本''name =''value1''></td> </tr> < tr> < td>油< td> < td><输入类型=文本''name =''value2''></td> </tr> < tr> < td>火花塞</td> < td><输入类型=文本''name =''value3''></td> </tr> < tr> < th colspan = 2><输入类型=''提交''value =''提交订单''名称=''提交1''> <选择名称=菜单''> <选择的选项>我是普通客户</option> < option>电视广告</option> < option>电话目录</option> < option>口碑</option> </select> </th> </tr> </table> </form> </body> </html>; 如果(
htmltag="<html> <body> <form method=''post'' action=''activity.php''> <table> <tr> <td bgcolor=''gray''>Item</td> <td bgcolor=''gray''>Quantity</td> </tr> <tr> <td>Tires</td> <td><input type=''text'' name=''value1''></td> </tr> <tr> <td>Oil</td> <td><input type=''text'' name=''value2''></td> </tr> <tr> <td>Spark Plugs</td> <td><input type=''text'' name=''value3''></td> </tr> <tr> <th colspan=2><input type=''submit'' value=''SUBMIT ORDER'' name=''submit1''> <select name=''menu''> <option selected>I''m A Regular Customer</option> <option>TV Advertising</option> <option>Phone Directory</option> <option>Word of Mouth</option> </select> </th> </tr> </table> </form> </body> </html>"; if (


_POST [''submit1'']) { 回声< font size =''12" font face =``Arial''> BOBS AUTO PARTS</font>; echo< br>< font size =''10''font face =``Arial''>订购结果</font>"; 回声< br>< br>"; 回声< br>< font face =''Arial">在; echo< br>< br>";
_POST[''submit1'']) { echo "<font size=''12'' font face = ''Arial''>BOBS AUTO PARTS</font>"; echo "<br><font size=''10'' font face = ''Arial''>Order Results</font>"; echo "<br><br>"; echo "<br><font face = ''Arial''>Order Processed at "; echo "<br><br>";


轮胎=


这篇关于简单的计算代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆