管理者的修改產品資料,點選後會連結到:modifyProduct1.php,可以以下拉式選單選取品牌、產品類別,
或是以方式輸入要找尋產品名稱、產品編號,收尋結果顯示在:doModifyProduct1.php
產品 ID 無法更改,一定要跟改的話則是以刪除產品後重新建立,而品牌、類別則是以點選選擇來更改如:
Upload.html
<?
/* 連接資料庫 */
require("db.php");
註解:呼叫db.php 檔
$input1=$_COOKIE["input1"];
註解:為關鍵字收尋,欄位名稱為input1 輸入內容存入函數$input1 中
$input2=$_COOKIE["input2"];
註解:為產品類別收尋 $input3=$_COOKIE["input3"];
註解:為品牌收尋 $temp_input2=$input2;
註解:設$temp_input2 為$input2 的值 $temp_input3=$input3;
if($input2=="null") $temp_input2="";
註解:假如$input2 的內容為空白的,$temp_input2 的內容為空字串 if($input3=="null")
$temp_input3="";
註解:假如$input3 的內容為空白的,$temp_input3 的內容為空字串
if(($input1=="")&&($input2=="null")&&($input3=="null"))
註解:如果( input1 為空字串,且 input2 為空白並且 input3 也為空白(3 個條件都符合) {
header ("Location:modifyProduct1.php");
註解:移到modifyProduct1.php }
if(($input1=="")&&($input2!="null")&&($input3=="null"))
註解:如果$input1 的內容為空字串且$input2 的內容不等於空白,並且 input3 也為空白 {
$sql1="SELECT * from product where sClass='$input2' order by nPrice ";
註解:到資料庫中的product 表單,將 sClass 欄位中符合 input2 的資料的輸出,並以 nPrice 欄位排序 }
if(($input1=="")&&($input2=="null")&&($input3!="null"))
註解:如果$input1 的內容為空字串且$input2 的內容為空白,並且 input3 也為空白 {
$sql1="SELECT * from product where sBrand='$input3' order by nPrice ";
註解:到資料庫中的product 表單,將 sBrand 欄位中符合 input3 的資料的輸出,並以 nPrice 欄位排序 }
if(($input1=="")&&($input2!="null")&&($input3!="null"))
註解:如果$input1 的內容為空字串且$input2 的內容不等於空白,並且 input3 也不等於空白 {
$sql1="SELECT * from product where sClass='$input2' and sBrand='$input3' order by nPrice ";
註解:到資料庫中的product 表單,將 sClass 欄位中與 sBrand 欄位中符合 input2 與 input3 的資料的輸 出,並以nPrice 欄位排序
}
if(($input1!="")&&($input2=="null")&&($input3=="null"))
註解:如果$input1 的內容不等於空字串且$input2 的內容為空白,並且 input3 也為空白 {
$sql1="SELECT * from product where sPName like '%$input1%' order by nPrice ";
註解:到資料庫中的product 表單,將 sPName(產品名稱)欄位中符合 input1 的資料的輸出,並以 nPrice 欄位排序,至於sPName like '%$input1%'與上面的 sClass='$input2'不同的原因,是 input1 為輸入字元要 加%已表示為字串。而 input2 和 input3 為以設定好預設值因此不需加入%。
}
if(($input1!="")&&($input2!="null")&&($input3=="null"))
註解:如果$input1 的內容不等於空字串且$input2 的內容也不等於空白,並且 input3 也為空白
{
$sql1="SELECT * from product where sPName like '%$input1%' and sClass='$input2' order by nPrice ";
註解:到資料庫中的product 表單,將 sPName(產品名稱)欄位中符合 input1,且 sClass 欄位中符合 input2 的資料的輸出(2 個都要符合),並以 nPrice 欄位排序
}
if(($input1!="")&&($input2=="null")&&($input3!="null"))
註解:如果$input1 的內容不等於空字串且$input2 的內容等於空白,並且 input3 不等於空白 {
$sql1="SELECT * from product where sPName like '%$input1%' and sBrand='$input3' order by nPrice ";
註解:到資料庫中的product 表單,將 sPName(產品名稱)欄位中符合 input1,且 sBrand 欄位中符合 input3 的資料的輸出(2 個都要符合),並以 nPrice 欄位排序
}
if(($input1!="")&&($input2!="null")&&($input3!="null"))
註解:如果$input1 的內容不等於空字串且$input2 的內容不等於空白,並且 input3 也不等於空白 {
$sql1="SELECT * from product where sPName like '%$input1%' and sClass='$input2' and sBrand='$input3' order by nPrice ";
註解:到資料庫中的product 表單,將 sPName 欄位中符合 input1,且 sClass 欄位中符合 input2 的資料,
並且sBrand 欄位中符合 input3 的資料的輸出(3 個都要符合),並以 nPrice 欄位排序
echo "<br><p align=center><font size=5 color=#0000ff>很抱歉! 查無您所需的資料<br><br>";
註解:搜尋結果若無,頁面則會顯示很抱歉! 查無您所需的資料,顏色為#0000ff echo "<b><a href=modifyProduct1.php><font color=#9900CC>
<span style=text-decoration: none>回產品修改主選單
註解:點選頁面顯示的回產品修改主選單連接回modifyProduct1.php,顏色為#9900CC
</td></tr></span></font></a></b>";
exit;
}
$show=ceil($total/1); ?>
<img border="0" src="../image/ym_ic_00.gif" width="11" height="10"><b><font color="#9900CC">商品搜尋 結果 :</font></b></td>
註解:頁面左上方顯示商品搜尋結果,顏色為#9900CC
<?
for ($i=1;$i<=$show;$i++) {
echo "<a href=doModifyProduct1.php?page=$i>$i</a>  ";
}
$page=$_GET["page"];
註解:取得到頁數 if (empty($page)) $page=1;
$start=1*($page-1);
if(($input1=="")&&($input2!="null")&&($input3=="null"))
註解:如果$input1 的內容等於空字串且$input2 的內容不等於空白,並且 input3 等於空白 {
$sql2="SELECT * from product where sClass='$input2' order by nPrice limit $start,1 ";
註解:到資料庫中的product 表單,將 sClass (產品名稱)欄位中符合 input2 的資料的輸出,並以 nPrice 欄位排序
}
if(($input1=="")&&($input2=="null")&&($input3!="null"))
註解:如果$input1 的內容等於空字串且$input2 的內容等於空白,並且 input3 不等於空白 {
$sql2="SELECT * from product where sBrand='$input3' order by nPrice limit $start,1 ";
註解:到資料庫中的product 表單,將 sBrand (產品名稱)欄位中符合 input3 的資料的輸出,並以 nPrice 欄位排序
}
if(($input1=="")&&($input2!="null")&&($input3!="null"))
註解:如果$input1 的內容等於空字串且$input2 的內容不等於空白,並且 input3 也不等於空白 {
$sql2="SELECT * from product where sClass='$input2' and sBrand='$input3' order by nPrice limit $start,1
";
註解:到資料庫中的product 表單,將 sClass (產品名稱)欄位中符合 input2,且 sBrand 欄位中符合 input3 的資料的輸出(2 個都要符合),並以 nPrice 欄位排序
}
if(($input1!="")&&($input2=="null")&&($input3=="null"))
註解:如果$input1 的內容不等於空字串且$input2 的內容等於空白,並且 input3 也等於空白
{
$sql2="SELECT * from product where sPName like '%$input1%' order by nPrice limit $start,1 ";
註解:到資料庫中的product 表單,將 sPName 欄位中符合 input1 的資料的輸出,並以 nPrice 欄位排序
}
if(($input1!="")&&($input2!="null")&&($input3=="null"))
註解:如果$input1 的內容不等於空字串且$input2 的內容不等於空白,並且 input3 等於空白 {
$sql2="SELECT * from product where sPName like '%$input1%' and sClass='$input2' order by nPrice limit
$start,1 ";
註解:到資料庫中的product 表單,將 sPName 欄位中符合 input1,且 sClass 欄位中符合 input2 的資料
的輸出(2 個都要符合),並以 nPrice 欄位排序
}
if(($input1!="")&&($input2=="null")&&($input3!="null"))
註解:如果$input1 的內容不等於空字串且$input2 的內容等於空白,並且 input3 不等於空白
{
$sql2="SELECT * from product where sPName like '%$input1%' and sBrand='$input3' order by nPrice limit $start,1 ";
註解:到資料庫中的product 表單,將 sPName 欄位中符合 input1,且 sBrand 欄位中符合 input3 的資 料的輸出(2 個都要符合),並以 nPrice 欄位排序
}
if(($input1!="")&&($input2!="null")&&($input3!="null"))
註解:如果$input1 的內容不等於空字串且$input2 的內容不等於空白,並且 input3 也不等於空白
{
$sql2="SELECT * from product where sPName like '%$input1%' and sClass='$input2' and sBrand='$input3' order by nPrice limit $start,1 ";
註解:到資料庫中的product 表單,將 sPName 欄位中符合 input1,且 sClass 欄位中符合 input2 的資料,
並且sBrand 欄位中符合 input3 的資料的輸出(3 個都要符合),並以 nPrice 欄位排序 }
$result=mysql_query($sql2);
$total=mysql_num_rows($result);
?>
</p>
<TABLE cellSpacing=0 cellPadding=0 width=804 align=center border=0>
<?
while($row=mysql_fetch_row($result)) { ?>
<tr>
<td width="426">
<form name=myFORM method="post" action="WriteModifyProduct1.php"
enctype="multipart/form-data">
<table border="0" width=940 id="table1">
<tr>
<td align="right" width="242">
<font size="2"> </font><font size="2" color="#cc70DB">產品 ID : </font>
<input type=text name="sPID1" disabled size=17 style=color:#0000FF value="<? echo $row[0];?>" >
註解:sPID1 欄位表單大小為 17 個字,顏色:#0000FF,內容值則由$row 佇列中的第 1 個欄位
<input type=hidden name="sPID" size=17 value="<? echo $row[0];?>" >
<input type=hidden name="page" size=5 value="<? echo $page;?>" >
</td>
<td align="right" width="233">
<font color=#cc70DB size="2">產品名稱 : </font>
<input type=text name="sPName" size=17 style=color:#0000FF value="<? echo
$row[1];?>" ></td>
<td align="right" width="261">
<font size="2" color="#cc70DB">產品描述 : </font>
<input type=text name="sDescription" size=15 style=color:#0000FF value="<? echo $row[2];?>" >
註解:sDescription 欄位表單大小為 15 個字,顏色:#0000FF,內容值則由$row 的第 3 個欄位(列)
</td>
<td align="right" width="186">
<font size="2"> </font><font size="2" color="#cc70DB">Model :
</font><input type=text name="sModel" size=10 style=color:#0000FF value="<? echo
$row[5];?>" >
</td>
</tr>
<tr>
<td align="right" width="242">
<font size="2"> </font><font size="2" color="#cc70DB">品牌 : </font>
<input type=text name="sBrand1" disabled size=17 style=color:#0000FF value="<? echo $row[4];?>" >
註解:sBrand1 欄位表單大小為 17 個字,顏色:#0000FF,內容值則由$row 的第 5 個欄位(列)
<input type=hidden name="sBrand" size=17 style=color:#0000FF value="<? echo $row[4];?>" >
</td>
<td align="right" width="233">
<font size="2" color="#CC70DB">類別</font><font size="2"> : </font>
</font>
<input type=text name="sClass1" disabled size=17 style=color:#0000FF value="<? echo $row[3];?
>" >
<input type=hidden name="sClass" size=17 style=color:#0000FF value="<? echo $row[3];?>" >
</td>
<td align="right" width="261">
<font color=#cc70DB size="2">進貨成本 : </font>
<input type=text name="nCost" size="15" style="color:#0000FF" value="<? echo $row[6];?
>"></td>
<td align="right" width="186">
<font size="2" color="#0000CC">目前庫存量 :</font><font size="2" color="#660066">
</font>
<input type=text name="nStock" size=10 style=color:#008000 value="<? echo $row[9];?>"
></td>
</tr>
<tr>
<td align="right" width="242">
<INPUT TYPE="button" VALUE="選擇" onClick="OpenItem()" style="background-color: #FF99FF">
<INPUT TYPE="button" VALUE="結束選擇" onClick="CloseItem()" style="background-color:
#00FFFF">
<input type="button" value="管理" onClick="window.open('ManageBrand.php')">
註解:點選管理的按鈕會連結到ManageBrand.php
</td>
<td align="right" width="233">
<INPUT TYPE="button" VALUE="選擇" onClick="OpenClass()" style="background-color: #FF99FF">
<INPUT TYPE="button" VALUE="結束選擇" onClick="CloseClass()" style="background-color:
#00FFFF">
<input type="button" value="管理" onClick="window.open('ManageClass.php')">
</td>
<td align="right" width="261">
<font size="2" color="#CC0000">是否為熱門商品:</font><font size="2"> </font> <input type=text name="hot" size=10 style=color:#0000FF value="<? echo $row[14];?>" ><font size="2">
</font>
<select size="1" name="hot_temp">
<option value="null">---</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select><font color=#cc70DB size="2"> </font>
</td>
<td align="right" width="186">
<font size="2" color="#0000CC">安全庫存量 :</font><font size="2" color="#cc70DB">
</font><input type=text name="nAlarmStock" size=10 style=color:#0000FF value="<? echo
$row[10];?>" ><font size="2">
</font>
</td>
</tr>
<tr>
<td align="right" width="242">
<font color="#CC70DB"> <font color=#cc70DB size="2">圖片檔名 : </font>
<input type=text name="sPicName" size=17 style=color:#0000FF value="<? echo $row[12];?>" ></td>
<td align="right" width="233">
<font color="#CC70DB">
<font size="2">表準售價 :</font> </font> </font></font><input type=text name="nPrice" size=10 style=color:#0000FF value="<? echo $row[7];?>" >
</td>
<td align="right" width="261">
<font color=#cc70DB size="2"> </font><font color=#CC0000 size="2">是否促銷 : </font><input type=text name="sPromoting" size=10 style=color:#0000FF value="<? echo $row[8];?>" >
<select size="1" name="sPromoting_temp">
<option value="null">---</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select><font size="2"> </font>
</td>
<td align="right" width="186">
<font color=#cc70DB size="2">表準出貨期 : </font><input type=text name="sLeadTime"
size=10 style=color:#0000FF value="<? echo $row[11];?>" ></td>
</tr>
<tr>
<td colspan="2" align="left">
<p align="center">
<font size="2" color="#CC70DB">更改圖片 : </font>
<input type="file" name="upload">
<img border="0" src="<? echo $row[12];?>" >
</td>
<td align="right">
<p align="left"><font color=#cc70DB>備註 : </font>
<textarea rows=8 cols=24 name="sRemark" size=10 style=color:#0000FF ><? echo
$row[13];?> </textarea>
</td>
<td align="right">
<p align="left"><input type="submit" value="確定修改" name="B1" >
<p>
<input type="submit" value="刪除" name="B1" style="float: left; color: #CC3300" >
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td><hr style="border-style: dotted; border-width: 0">
</td>
</tr>
<?
}
?>