自学PHP的笔记(七)小例子两头
来源:互联网 发布:js视频 编辑:程序博客网 时间:2024/05/08 17:11
第一个
<html>
<head>
<title>Lee's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
//定义变量
$totalqty = 0;
$totalamount = 0.00;
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['spqty'];
$find = $_POST['find'];
$taxrate=0.00;
//定义常量
define('TLREPRICE',100);
define('OILPRICE',10);
define('SPAKPRICE',4);
//计算订单购买件数
$totalqty = $tireqty + $oilqty + $sparkqty;
echo '<p>Your order is as follows;</p>';
if($totalqty == 0){
echo 'You did not order anything on the previous page! <br/>';
}else{
if($tireqty > 0){
echo $tireqty.'tires<br />';
}
if($oilqty > 0){
echo $oilqty.'bottles of oil<br />';
}
if($sparkqty > 0){
echo $sparkqty.'spark plugs<br />';
}
switch($find){
case "a":
echo 'Regular customer.<br/>';
break;
case "b":
echo 'Customer referred by TV advert.<br/>';
break;
case "c":
echo 'Customer referred by phone directory<br/>';
break;
case "d":
echo 'Customer referred by word of mouth.v';
break;
default :
echo 'We do not know how this customer found us.<br/>';
break;
}
//计算总价
$totalamount = $tireqty * TLREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPAKPRICE;
echo "Items orderd: ".$totalqty."<br/>";
echo "Subtotal: $".number_format($totalamount,2)."<br />";
if($totalqty < 10 ){
$taxrate=0.00;
}elseif($totalqty >= 10 && $totalqty <= 49)
{
$taxrate=0.05;
}elseif($totalqty >= 50 && $totalqty <= 99)
{
$taxrate=0.10;
}elseif($totalqty >= 100)
{
$taxrate=0.15;
}
echo "Discount:".$taxrate." Taxrate:0.1<br/>";
//计算税后总价
$totalamount=$totalamount*1.1*(1-$taxrate);
echo "Total including tax:$".number_format($totalamount,2)."<br/>";
}
?>
</body>
</html>
<form action="ProcessOrder.php" method="post">
<table border ="0">
<tr bgcolor="#cccccc">
<td width="150">Item</td>
<td>Quantity</td>
<tr/>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3"/></td>
<tr/>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"/></td>
<tr/>
<tr>
<td>Spark Plugs</td>
<td align="center"><input type="text" name="spqty" size="3" maxlength="3"/></td>
<tr/>
<tr>
<td>How did you find Bob?</td>
<td><select name = "find">
<option value = "a">I'm a regular customer</option>
<option value = "b">TV advertising</option>
<option value = "c">Phone directory</option>
<option value = "d">Word of mouth</option>
</select>
</td>
</td>
<tr>
<td align="center"><input type="submit" value="Submit Order"/></td>
<tr/>
</table>
</form>
第二个
<?php
$pictures= array('1.bmp','2.bmp','3.bmp','4.bmp','5.bmp','6.bmp','7.bmp','8.bmp','9.bmp','10.bmp');
shuffle($pictures);
?>
<html>
<head>
<title>Bob's Auto Parts</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<div align="center">
<table>
<tr>
<?php
for($i=0;$i<3;$i++){
echo "<td align=\"center\"><img src=\"image/";
echo $pictures[$i];
echo "\"width=\"399\"/></td>";
}
?>
</tr>
</table>
</div>
</body>
</html>
- 自学PHP的笔记(七)小例子两头
- OpenCV 自学笔记30. 简单轮廓匹配的小例子
- QT自学笔记(七)
- 自学PHP的笔记(一)
- 自学PHP的笔记(二)
- 自学PHP的笔记(三)
- 自学PHP的笔记(四)埋个雷
- 自学PHP的笔记(五)
- PHP 递归小例子笔记
- OpenCV自学笔记26. 写一个ROI叠加的小例子
- 学习笔记-去掉字符串两头的空格
- OpenCV自学笔记16. 卡尔曼滤波器小例子
- 一个php的小例子
- 小白 自学PHP
- 自学PHP的笔记(六)注释标记数组排序
- (例子)PHP 数据抓取小例子
- 1、我的php自学笔记开始
- 自学前端小笔记
- UC故事2011/11/29
- 解决vs03 安装中可恶的FrontPage 2000 WEB
- 算法入门--计数排序
- ORACLE的analyze使用简介 (转载)
- 使用 FileNet Content API 开发以内容为核心的流程
- 自学PHP的笔记(七)小例子两头
- Error #2044: 未处理的 AsyncErrorEvent
- 使用LinkedList实现Queue
- text-decoration:line-through;删除线相对字不在中间
- 配置SSH自动登录
- 移植Android3.0 SDK到freescale imx51_bbg总结
- C++举出与技巧【set容器、multimap 和 multiset】
- 转载:ubuntu全程配置手册
- android中导入低版本project可能会遇到的编译问题