这个点菜页面的问题如何解决

doney_0318 2009-08-23 04:37:12
http://www.okdays.net/cy/main/diy.php



这里是产品的一个点菜页面,客户在这里对需要的产品进行打勾,填入相应数量,确认后提交到下一个页面,在下一个面面显示客户所选择商品的ID 名称 价格 数量 



diy.php 这里页面里的表单名称是

引用
<form action="cart.php" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td width="20" height="1"> </td>
<td colspan="4" class="header">点菜单</td>
</tr>

<tr>
<td height="25"> </td>
<td width="100" align="center" bgcolor="#CCCCCC" class="con3">选中</td>
<td width="350" align="center" bgcolor="#CCCCCC">菜名</td>
<td width="100" align="center" bgcolor="#CCCCCC">单价</td>
<td width="100" align="center" bgcolor="#CCCCCC">数量</td>
</tr>
<!-- BEGIN DC -->
<tr>
<td width="20" height="25"></td>
<td align="center" class="con3"><input name='ProductID[]' type='checkbox' onClick="unselectall()" id="ProductID[]" value='{ID}' style="border: 0px;background-color: #eeeeee;">
<input type="hidden" name="ID[]" id="ID[]" value="{ID}"/>
</td>
<td>{Atitle}</td>
<td align="right">{Aprice}</td>
<td align="center"><input name="sl[]" type="text" id="sl[]" size="8" value="0"/></td>
</tr>
<!-- END DC -->

<tr>
<td height="50" align="center"></td>
<td height="50" align="center"><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" style="border: 0px;background-color: #eeeeee;"></td>
<td height="50" colspan="3" align="center">
<input type="image" name="imageField" src="../images/xyb.gif" /> </td>
</tr>
</table>
</form>




表单提交页cart.php里的内容

引用
$dc=array();
for ($i=0;$i<count($_POST['ID']);$i++){
$dc[] = array('id'=>$_POST[$i]['ID'],'sl'=>$_POST[$i]['sl']);
}

$ProductID= $_POST['ProductID'];
if(is_array($ProductID)){
$ids = $comma = "";
foreach($ProductID as $id){
$ids .= "{$comma}{$id}";
$comma = ",";
}}
$sqlids="select ID,Atitle,Aprice from Product Where ID IN ({$ids})";
$sqlids = $db->execute($sqlids);
$sqlids = $sqlids->GetRows();

$id_map = array();
foreach ($dc as $row) {
$id_map[$row['id']] = $row['sl'] ;
}
foreach ($sqlids as $key => $row) {
if (isset($id_map[$row['id']])) {
$sqlids[$key]['sl'] = $id_map[$row['id']];
}else{
$sqlids[$key]['sl'] = '0';
}
}




我就是这么写的,可是提交出来的东西始终没有数量的值,这个应该如何解决
...全文
95 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
LuciferStar 2009-08-23
  • 打赏
  • 举报
回复
表单接受页面,建议用
print_r($_REQUEST);
看一下。
这个$_REQUEST包括了:
$_POST
$_GET
$_COOKIE
$_SESSION

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧