<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>
$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'; } }
21,893
社区成员
140,347
社区内容
加载中
试试用AI创作助手写篇文章吧