[請益]為什麼會出現兩筆商品訂購資料

看板PHP作者 (■■■■■■■■■■■)時間14年前 (2011/11/04 01:10), 編輯推噓-1(126)
留言9則, 7人參與, 最新討論串1/1
<?php require_once('Connections/db_conn.php'); ?> <?php mysql_query("SET NAMES UTF8"); ini_set('default_charset','utf-8'); if (!isset($_SESSION)) { session_start(); } if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "delform")) { $updateSQL = sprintf("UPDATE shop_car SET goods_price=%s, ord_num=%s, ord_sum=%s WHERE temp_no=%s", GetSQLValueString($_POST['goods_price'], "int"), GetSQLValueString($_POST['ord_num'], "int"), GetSQLValueString($_POST['goods_price'], "int")*GetSQLValueString($_POST['ord_num'], "int"), GetSQLValueString($_POST['temp_no'], "int")); mysql_select_db($database_db_conn, $db_conn); $Result1 = mysql_query($updateSQL, $db_conn) or die(mysql_error()); $updateGoTo = "shop_car.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } if ((isset($_GET['temp_no'])) && ($_GET['temp_no'] != "") && (isset($_GET['del']))) { $deleteSQL = sprintf("DELETE FROM shop_car WHERE temp_no=%s", GetSQLValueString($_GET['temp_no'], "int")); mysql_select_db($database_db_conn, $db_conn); $Result1 = mysql_query($deleteSQL, $db_conn) or die(mysql_error()); $deleteGoTo = "shop_car.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } mysql_select_db($database_db_conn, $db_conn); $query_showitemRec = "SELECT * FROM shop_item"; $showitemRec = mysql_query($query_showitemRec, $db_conn) or die(mysql_error()); $row_showitemRec = mysql_fetch_assoc($showitemRec); $totalRows_showitemRec = mysql_num_rows($showitemRec); $colname_carRec = "-1"; if (isset($_SESSION['tempord_id'])) { $colname_carRec = $_SESSION['tempord_id']; } mysql_select_db($database_db_conn, $db_conn); $query_carRec = sprintf("SELECT * FROM shop_car WHERE ord_id = %s ORDER BY temp_no DESC", GetSQLValueString($colname_carRec, "text")); $carRec = mysql_query($query_carRec, $db_conn) or die(mysql_error()); $row_carRec = mysql_fetch_assoc($carRec); $totalRows_carRec = mysql_num_rows($carRec); ?> </table><br /> <table width="750" border="0" align="center" cellpadding="0" cellspacing="0"> <tr valign="top"> <td><table width="750" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="170" valign="top"><?php do { ?> <table width="170" border="0" align="center" cellpadding="0" cellspacing="0" id="item"> <tr> <td colspan="2" background="../Chaoyang_Food/images/mod_nw.gif"></td> <td width="5"><img src="../Chaoyang_Food/images/mod_ne.gif" width="5" height="5" /></td> </tr> <tr> <td width="5" background="../Chaoyang_Food/images/mod_left.gif"><img src="../Chaoyang_Food/images/mod_left.gif" width="5" height="5" /></td> <td width="160" bgcolor="#7894AF"><p class="style8 style18"><?php echo $row_showitemRec['item_name']; ?></p></td> <td rowspan="2" background="../Chaoyang_Food/images/mod_right.gif"></td> </tr> <tr> <td background="../Chaoyang_Food/images/mod_left.gif"></td> <td width="160" rowspan="3" bgcolor="#EFEFF8"><table width="100%" border="0" cellpadding="0" cellspacing="0" id="goods"> <?php mysql_select_db($database_db_conn, $db_conn); $query_showgoodsRec = sprintf("SELECT * FROM shop_goods WHERE item_id = %s", GetSQLValueString($row_showitemRec['item_id'], "text")); $showgoodsRec = mysql_query($query_showgoodsRec, $db_conn) or die(mysql_error()); $row_showgoodsRec = mysql_fetch_assoc($showgoodsRec); $totalRows_showgoodsRec = mysql_num_rows($showgoodsRec); if ($totalRows_showgoodsRec > 0) { do {?> <tr> <td width="9%"><img src="../Chaoyang_Food/images/arrows_blue.gif" width="15" height="21" /></td> <td width="91%"><a href="shop_goods.php?goods_id=<?php echo $row_showgoodsRec['goods_id']; ?>"> <?php echo $row_showgoodsRec['goods_name']; ?> </a></td></tr> <?php } while ($row_showgoodsRec = mysql_fetch_assoc($showgoodsRec)); }?> </table></td> </tr> <tr> <td background="../Chaoyang_Food/images/mod_left.gif"></td> <td background="../Chaoyang_Food/images/mod_right.gif"></td> </tr> <tr> <td background="../Chaoyang_Food/images/mod_left.gif"></td> <td background="../Chaoyang_Food/images/mod_right.gif"></td> </tr> <tr> <td colspan="2" background="../Chaoyang_Food/images/mod_sw.gif"></td> <td><img src="../Chaoyang_Food/images/mod_se.gif" width="5" height="5" /></td> </tr> <tr> <td height="10" colspan="3"></td> </tr> </table> <?php } while ($row_showitemRec = mysql_fetch_assoc($showitemRec)); ?></p> </p> </p></p></td> <td width="580" align="right" valign="top"><table width="560" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" background="../Chaoyang_Food/images/mod_nw.gif"></td> <td width="5"><img src="../Chaoyang_Food/images/mod_ne.gif" width="5" height="5" /></td> </tr> <tr> <td width="5" background="../Chaoyang_Food/images/mod_left.gif"><img src="../Chaoyang_Food/images/mod_left.gif" width="5" height="5" /></td> <td width="550" bgcolor="#9DACBF"><p align="left" class="style19"><span class="style22">檢視購物車</span>(如出現商品有重複購買情形,請刪除其中一個,請各位見諒!)</p></td> <td rowspan="2" background="../Chaoyang_Food/images/mod_right.gif"></td> </tr> <tr> <td background="../Chaoyang_Food/images/mod_left.gif"></td> <td width="550" bgcolor="#FFFFFF"><div align="center"> <?php if ($totalRows_carRec > 0) { // Show if recordset not empty ?> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="38%"><div align="left" class="style21">品名</div></td> <td width="9%"><div align="left" class="style21">數量</div></td> <td width="12%"><div align="left" class="style21">單價</div></td> <td width="16%"><div align="left" class="style21">小計</div></td> <td width="25%"><div align="left"></div></td> </tr> <?php $total=0; do { ?> <tr> <form method="POST" action="<?php echo $editFormAction; ?>" name="delform" id="delform"> <td><div align="left"><strong><?php echo $row_carRec['goods_name']; ?></strong></div></td> <td><div align="left"> <select name="ord_num" id="ord_num"> <option value="5" <?php if (!(strcmp(5, $row_carRec['ord_num']))) {echo "selected=\"selected\"";} ?>>5</option> <option value="10" <?php if (!(strcmp(10, $row_carRec['ord_num']))) {echo "selected=\"selected\"";} ?>>10</option> <option value="15" <?php if (!(strcmp(15, $row_carRec['ord_num']))) {echo "selected=\"selected\"";} ?>>15</option> <option value="20" <?php if (!(strcmp(20, $row_carRec['ord_num']))) {echo "selected=\"selected\"";} ?>>20</option> <option value="25" <?php if (!(strcmp(25, $row_carRec['ord_num']))) {echo "selected=\"selected\"";} ?>>25</option> </select> </div></td> <td><div align="left"><strong>NT$<?php echo $row_carRec['goods_price']; ?></strong></div></td> <td><div align="left"><strong>NT$<?php echo $row_carRec['ord_sum']; ?></strong></div></td> <td><input name="temp_no" type="hidden" id="temp_no" value="<?php echo $row_carRec['temp_no']; ?>" /> <input name="goods_price" type="hidden" id="goods_price" value="<?php echo $row_carRec['goods_price']; ?>" /> <input type="submit" name="button" id="button" value="修改" /> <input name="del" type="button" id="del" onclick="MM_goToURL('parent','shop_car.php?del=true&amp;temp_no=<?php echo $row_carRec['temp_no']; ?>');return document.MM_returnValue" value="刪除" /></td> <input type="hidden" name="MM_update" value="delform" /> </form> </tr> <?php $total=$total+($row_carRec['ord_num']*$row_carRec['goods_price']); } while ($row_carRec = mysql_fetch_assoc($carRec)); ?> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td><div align="right"><strong>總計NT$</strong></div></td> <td><div align="left"><?php echo $total; ?></div></td> </tr> </table> <?php } // Show if recordset not empty ?> <input name="button2" type="button" id="button2" onclick="MM_goToURL('parent','shop_index.php');return document.MM_returnValue" value="繼續購物" /> <?php if ($totalRows_carRec > 0) { // Show if recordset not empty ?> <input name="button3" type="button" id="button3" onclick="MM_goToURL('parent','shop_order.php');return document.MM_returnValue" value="立即送出" /> <?php } // Show if recordset not empty ?> <br /> </div></td> 能幫我看看哪裡有bug嗎? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.17.9.105

11/04 07:33, , 1F
等你不會把dreamweaver產生的原始碼po上來時。
11/04 07:33, 1F

11/04 07:33, , 2F
我想應該比較會有人來幫你解你的問題。
11/04 07:33, 2F

11/04 09:37, , 3F
好難看
11/04 09:37, 3F

11/04 10:05, , 4F
不知道
11/04 10:05, 4F

11/04 15:31, , 5F
不能,不客氣。
11/04 15:31, 5F

11/04 18:06, , 6F
本來想說貼到editor 裡面看看到底怎樣的
11/04 18:06, 6F

11/04 22:38, , 7F
BUG就是, 你用DW做了不該做的事
11/04 22:38, 7F

11/05 00:40, , 8F
…結果看到有11頁就放棄。上班時間沒那麼閒。
11/05 00:40, 8F

11/05 02:48, , 9F
看到這種code style難怪有人要一直加班...
11/05 02:48, 9F
文章代碼(AID): #1Eiihv2M (PHP)
文章代碼(AID): #1Eiihv2M (PHP)