作者Obadiah (■■■■■■■■■■■)
看板PHP
标题[请益]为什麽会出现两笔商品订购资料
时间Fri Nov 4 01:10:12 2011
<?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&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> </td>
<td> </td>
<td> </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
1F:→ tkdmaf:等你不会把dreamweaver产生的原始码po上来时。 11/04 07:33
2F:→ tkdmaf:我想应该比较会有人来帮你解你的问题。 11/04 07:33
3F:→ angelmark:好难看 11/04 09:37
4F:嘘 UniFish:不知道 11/04 10:05
5F:嘘 yanli2:不能,不客气。 11/04 15:31
6F:→ MOONRAKER:本来想说贴到editor 里面看看到底怎样的 11/04 18:06
7F:推 cokellen:BUG就是, 你用DW做了不该做的事 11/04 22:38
8F:→ MOONRAKER:…结果看到有11页就放弃。上班时间没那麽闲。 11/05 00:40
9F:→ shadowjohn:看到这种code style难怪有人要一直加班... 11/05 02:48