ตอนนี้กำลังทำเว็บไซต์เกี่ยวกับ E-commerce ใช้ PHP และ Phpmyadmin ตอนนี้มีปัญหาในหน้าของการเพิ่มข้อมูลสินค้า คือ เราสามารถเพิ่มข้อมูลได้แต่กลับไม่ขึ้นในฐานข้อมูล ทำไงดีค่ะ รบกวนช่วยดูหน่อยค่ะ
โค้ดหน้าเพิ่มข้อมูลสินค้า
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
a:link {
color: #0033FF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0000FF;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #0000FF;
}
.style6 {font-size: 2}
-->
</style></head>
</head>
<body>
<table width="804" border="1" align="center" bordercolor="#CCCCCC">
<tr valign="top" bordercolor="#CCCCCC">
<td colspan="3" ><?php include("headadmin.htm"); ?></td>
</tr>
<tr valign="top" bordercolor="#CCCCCC">
<td width="804" height="349" valign="middle" ><FORM METHOD=POST enctype="multipart/form-data" ACTION="addnewproduct.php">
<table width="350" border="0" align="center" bgcolor="#FF9900">
<tr>
<td><center>
<font color="black"><b>
</b></font>
<div align="center"><font color="black"><b>เพิ่มรายการพัสดุใหม่!!</b></font></div>
</center></td>
</tr>
<tr bgcolor="#DBDBDB">
<td bgcolor="#DBDBDB" > <font size="2">ประเภทพัสดุ :
<select name="producttype_id" id="select" selected="เลือกประเภทพัสดุ">
<?
include("connect.php");
connect();
$rsgroup = mysql_query("select * from product_type");
if($nrecgroup = mysql_num_rows($rsgroup)>0)
{
echo"<option value=nullgroup>เลือกประเภทพัสดุ</option>";
while($rowgroup = mysql_fetch_array($rsgroup))
{
$producttype_idxx= $rowgroup["producttype_id"];
$product_typexx = $rowgroup["product_type"];
?>
<option value ="<? echo $producttype_idxx;?>"><?echo $product_typexx; ?></option>
<?
}
}
?>
</select>
</font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2> ยี่ห้อ :
<input name=brand type id="brand" text >
</font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td ><font size=2> รุ่น :
<INPUT NAME=sub_product TYPe id="sub_product" text ></font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2> รายละเอียด :
<INPUT NAME=spec TYPe id="spec" text ></font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2>วันที่สั่งซื้อ :
<input name=date_buy type id="date_buy"></font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2>ข้อมูลร้านค้า :
<input name=store_data type id="store_data"></font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2>จำนวนใน Stock :
<INPUT NAME=stock TYPe id="stock" text >
ชิ้น</font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td> <font size=2>ไฟล์รูปภาพ :
<input type=file name=uploadfile>
</font></td>
</tr>
<tr>
<td><center>
<INPUT name="submit" TYPE="submit" value="Add">
</center></td>
</tr>
</table>
<p align="center">
<? //command add product data puts table product_stock
if(!empty($brand) && !empty($sub_product))
{
$rsconfig = mysql_query("select * from product order by product_id");
$x = mysql_num_rows($rsconfig);
if($x>0)
{
while($rowconfig = mysql_fetch_array($rsconfig))
{
$product_idx =$rowconfig["product_id"];
}
$product_idx++;
}else{
$product_idx=1;
}
if (isset($_FILES["uploadfile"]["name"]))
{
$uploaddir= "product/";
$uploadfile = $uploaddir.basename($_FILES['uploadfile']['name']);
// if(copy($uploadfile,$_FILES["uploadfile"]["name"]))
//{
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile))
{
$path =$_FILES["uploadfile"]["name"]; // Pathfile\
}
mysql_query("insert into product values('$product_idx','$producttype_id','$sub_product','$spec','$brand','$date_buy','$store_data','$stock','$path','$showproduct')");
echo"<font color=blue>.....เพิ่มรายการพัสดุใหม่เรียบร้อยแล้ว.....</font>";
//}
}
}
?>
</p>
<p align="center"><a href="menuadmin.php"><<|Admin_Systems </a></p>
</form>
</td>
</tr>
</table>
<div align="center">
<table width="804" border="1" align="center" bordercolor="#CCCCCC">
<tr valign="top" bordercolor="#CCCCCC">
<td colspan="3" ><?php include("footer.htm"); ?></td>
</tr>
</table>
</div>
</body>
</html>
ตอนนี้กำลังทำเว็บไซต์เกี่ยวกับ E-commerce ใช้ PHP และ Phpmyadmin ตอนนี้มีปัญหาในหน้าของการเพิ่มข้อมูลสินค้า คือ เราสามารถเพิ่มข้อมูลได้แต่กลับไม่ขึ้นในฐานข้อมูล ทำไงดีค่ะ รบกวนช่วยดูหน่อยค่ะ
โค้ดหน้าเพิ่มข้อมูลสินค้า
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
a:link {
color: #0033FF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0000FF;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #0000FF;
}
.style6 {font-size: 2}
-->
</style></head>
</head>
<body>
<table width="804" border="1" align="center" bordercolor="#CCCCCC">
<tr valign="top" bordercolor="#CCCCCC">
<td colspan="3" ><?php include("headadmin.htm"); ?></td>
</tr>
<tr valign="top" bordercolor="#CCCCCC">
<td width="804" height="349" valign="middle" ><FORM METHOD=POST enctype="multipart/form-data" ACTION="addnewproduct.php">
<table width="350" border="0" align="center" bgcolor="#FF9900">
<tr>
<td><center>
<font color="black"><b>
</b></font>
<div align="center"><font color="black"><b>เพิ่มรายการพัสดุใหม่!!</b></font></div>
</center></td>
</tr>
<tr bgcolor="#DBDBDB">
<td bgcolor="#DBDBDB" > <font size="2">ประเภทพัสดุ :
<select name="producttype_id" id="select" selected="เลือกประเภทพัสดุ">
<?
include("connect.php");
connect();
$rsgroup = mysql_query("select * from product_type");
if($nrecgroup = mysql_num_rows($rsgroup)>0)
{
echo"<option value=nullgroup>เลือกประเภทพัสดุ</option>";
while($rowgroup = mysql_fetch_array($rsgroup))
{
$producttype_idxx= $rowgroup["producttype_id"];
$product_typexx = $rowgroup["product_type"];
?>
<option value ="<? echo $producttype_idxx;?>"><?echo $product_typexx; ?></option>
<?
}
}
?>
</select>
</font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2> ยี่ห้อ :
<input name=brand type id="brand" text >
</font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td ><font size=2> รุ่น :
<INPUT NAME=sub_product TYPe id="sub_product" text ></font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2> รายละเอียด :
<INPUT NAME=spec TYPe id="spec" text ></font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2>วันที่สั่งซื้อ :
<input name=date_buy type id="date_buy"></font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2>ข้อมูลร้านค้า :
<input name=store_data type id="store_data"></font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td><font size=2>จำนวนใน Stock :
<INPUT NAME=stock TYPe id="stock" text >
ชิ้น</font></td>
</tr>
<tr bgcolor=#DBDBDB>
<td> <font size=2>ไฟล์รูปภาพ :
<input type=file name=uploadfile>
</font></td>
</tr>
<tr>
<td><center>
<INPUT name="submit" TYPE="submit" value="Add">
</center></td>
</tr>
</table>
<p align="center">
<? //command add product data puts table product_stock
if(!empty($brand) && !empty($sub_product))
{
$rsconfig = mysql_query("select * from product order by product_id");
$x = mysql_num_rows($rsconfig);
if($x>0)
{
while($rowconfig = mysql_fetch_array($rsconfig))
{
$product_idx =$rowconfig["product_id"];
}
$product_idx++;
}else{
$product_idx=1;
}
if (isset($_FILES["uploadfile"]["name"]))
{
$uploaddir= "product/";
$uploadfile = $uploaddir.basename($_FILES['uploadfile']['name']);
// if(copy($uploadfile,$_FILES["uploadfile"]["name"]))
//{
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile))
{
$path =$_FILES["uploadfile"]["name"]; // Pathfile\
}
mysql_query("insert into product values('$product_idx','$producttype_id','$sub_product','$spec','$brand','$date_buy','$store_data','$stock','$path','$showproduct')");
echo"<font color=blue>.....เพิ่มรายการพัสดุใหม่เรียบร้อยแล้ว.....</font>";
//}
}
}
?>
</p>
<p align="center"><a href="menuadmin.php"><<|Admin_Systems </a></p>
</form>
</td>
</tr>
</table>
<div align="center">
<table width="804" border="1" align="center" bordercolor="#CCCCCC">
<tr valign="top" bordercolor="#CCCCCC">
<td colspan="3" ><?php include("footer.htm"); ?></td>
</tr>
</table>
</div>
</body>
</html>