<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<link href="css.css" rel="stylesheet" type="text/css" />
<?php
$name = "洋娃娃@单反相机@盖世兔手机@瑞士名表";
$price = "15000@5800@4000@78000";
$counts = "1@2@3@4";
$arrid = explode("@", $name); //把名称变成一个数组
$arrnum = explode("@", $price); //把价格变成一个数组
$arrcout = explode("@", $counts); //把数量变成一个数组
if ($_POST[sub] == true){
$id = $_POST[name];
$num = $_POST[counts];
$key = array_search($id, $arrid); //传递回物品的名称,在检查名称所在的数组的键值,如洋娃娃,键值为0
$arrcout[$key]=$num; //改变想要键值的相应数量
$counts = implode("@", $arrcout); //再把修改成$counts原来的样子,然后传回$counts
}
?>
<table width="580" align="center" border="1" cellspacing="1" cellpadding="1" bordercolor="#ffffff" bgcolor="#c17e50">
<tr>
<td width="145" align="center" bgcolor="#ffffff" class="STYLE1">商品名称</td>
<td width="145" align="center" bgcolor="#ffffff" class="STYLE1">价格</td>
<td width="145" align="center" bgcolor="#ffffff" class="STYLE1">数量</td>
<td width="145" align="center" bgcolor="#ffffff" class="STYLE1">金额</td>
</tr>
<?php
for ($i=0;$i<count($arrid);$i++){
?>
<form name="form1_<?php echo $i;?>" action="index.php" method="post">
<tr>
<td height="25" align="center" bgcolor="#ffffff" class="STYLE2"><?php echo $arrid[$i]; ?></td> <!-- 显示商品名称 -->
<td height="25" align="center" bgcolor="#ffffff" class="STYLE2"><?php echo $arrnum[$i]; ?></td> <!-- 显示商品价格 -->
<td height="25" align="center" bgcolor="#ffffff" class="STYLE2">
<input name="counts" type="text" id="counts" value="<?php echo $arrcout[$i]; ?>" size="8"/> <!-- 显示商品数量 -->
<input name="name" type="hidden" id="name" value="<?php $arrid[$i]; ?>" />
<input name="sub" type="submit" value="提交"/>
</td>
<td height="25" align="center" bgcolor="#ffffff" class="STYLE2"><?php echo $arrcout[$i]*$arrnum[$i];?></td>
</tr>
</form>
<?php
}
?>
</table>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。