|
|
|
เพิ่มราคาพิเศษไม่ได้ครับ ข้อมูลไม่เพิ่มให้ใน database |
|
|
|
|
|
|
|
เพิ่มราคาพิเศษไม่ได้ครับ ข้อมูลไม่เพิ่มให้ใน database
Product addCode (PHP)
<?
session_start();
if($login_admin_true<>session_id())
{
header("Location: ../index.php");
exit();
}
include("../config.inc.php");
?>
<form name="checkPro" action="product_add2.php" method="post" enctype="multipart/form-data" onSubmit="return check()">
<center><p><font size="3" face="MS Sans Serif, Tahoma, sans-serif"><b>Add new products</b></font></p></center>
<table border="0" cellspacing="10" cellpadding="0" width="100%">
<tr>
<td width="30%" align="right"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">Name Product : </font></td>
<td width="70%" align="left"><input type="text" name="name" size="80" value="<?=$_POST['name']?>"> <font size="3" face="MS Sans Serif, Tahoma, sans-serif" color="red">*</font></td>
</tr>
<tr>
<td align="right"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">category : </font></td>
<td align="left"><select name="dv_id" onChange="location.href='product_add.php?dv_id='+this.value;">
<option value=""><font size="2" face="MS Sans Serif, Tahoma, sans-serif">Select category</font></option>
<?
$sql="select * from device";
$result=mysql_db_query($db,$sql);
while($rs=mysql_fetch_array($result)){
if($dv_id == $rs[dv_id]){ //à¾×èÍãËé áÊ´§ $cat_id ·ÕèÊ觤èÒÁÒãËé
?>
<option value="<?=$rs[dv_id];?>" selected="selected"><?=$rs[dv_name];?></option>
<? }else{?>
<option value="<?=$rs[dv_id];?>"><?=$rs[dv_name];?></option>
<?
//$type_id=$rs[type_id];
//$type_name=$rs[type_name];
//echo "<option value='$type_id'>$type_name</option>";
} }?>
</select> <font size="3" face="MS Sans Serif, Tahoma, sans-serif" color="red">*</font></td>
</tr>
<tr>
<td align="right">
<font size="3" face="MS Sans Serif, Tahoma, sans-serif">Type Product : </font></td>
<td><select name="md_id">
<option value=""><font size="2" face="MS Sans Serif, Tahoma, sans-serif">Select Type</font></option>
<?
//if($type_id != ""){
$sql2="select * from model where dv_id='$dv_id'";
$result2=mysql_db_query($db,$sql2);
while($rs2=mysql_fetch_array($result2)){
//$id_td=$rs2[id_td];
//$name_td=$rs2[name_td];
//echo "<option value='$id_td'>$name_td</option>";?>
<option value="<?=$rs2[md_id];?>"><?=$rs2[md_name];?></option>
<? }
?>
</select> <font size="3" face="MS Sans Serif, Tahoma, sans-serif" color="red">*</font></td>
</tr>
<tr>
<td align="right"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">Detail : </font></td>
<td><textarea name="detail" cols="40" rows="4"></textarea> <font size="3" face="MS Sans Serif, Tahoma, sans-serif" color="red">*</font></td>
</tr>
<tr>
<td align="right"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">Price : </font></td>
<td><input type="text" name="price" size="10">
<font size="3" face="MS Sans Serif, Tahoma, sans-serif">Bath</font> <font size="3" face="MS Sans Serif, Tahoma, sans-serif" color="red">*</font></td>
</tr>
<tr>
<td align="right"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">Special Price : </font></td>
<td><input type="text" name="Special Price" size="10">
<font size="3" face="MS Sans Serif, Tahoma, sans-serif">Bath</font> <font size="3" face="MS Sans Serif, Tahoma, sans-serif" color="red">*</font></td>
</tr>
<tr>
<td align="right"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">Pic : </font></td>
<td><input type="file" name="fileupload">
<input type="hidden" name="max_file_size" value="1000000"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Reset"></td>
</tr>
</table>
<script language="javascript">
function check() {
if(document.checkPro.name.value=="") {
alert("Please enter your name") ;
document.checkPro.name.focus() ;
return false ;
}
else if(document.checkPro.dv_id.value=="") {
alert("Please select a category") ;
document.checkPro.dv_id.focus() ;
return false ;
}
else if(document.checkPro.md_id.value=="") {
alert("Please select a model") ;
document.checkPro.md_id.focus() ;
return false ;
}
else if(isNaN(document.checkPro.detail.value=="")) {
alert("Please fill in the details too") ;
document.checkPro.detail.focus() ;
return false ;
}
else if(document.checkPro.price.value=="") {
alert("Please enter the Price") ;
document.checkPro.price.focus() ;
return false ;
}
else
return true ;
}
</script></form>
Product add2 (process ครับ)
Code (PHP)
<?
session_start();
if($login_admin_true<>session_id())
{
header("Location: ../index.php");
exit();
}
$name=$_POST[name];
$md_id=$_POST[md_id];
$detail=$_POST[detail];
$price=$_POST[price];
$sprice=$_POST[sprice];
$fileupload_name=$_FILES['fileupload']['name'];
//$id_td=$_POST[id_td];
if($name=="" or $md_id=="" or $detail=="" or $price==""){
header("Location: index_admin.php");
exit();
}
include("../config.inc.php");
$sql="insert into product values(null,'$name','$md_id','$detail','$price','$sprice','$fileupload_name')";
$result=mysql_db_query($db,$sql);
if($fileupload){
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg"){
$sql2="select max(prd_id) from product";
$result2=mysql_db_query($db,$sql2);
$row=mysql_fetch_array($result2);
$date = date("U"); //ÊÃéÒ§àÅ¢ 10 ËÅÑ¡ÁÒ¨Ò¡àÇÅÒ à¾×èÍàÍÒä»ãªéà»ç¹ª×èͧ͢ÃÙ» »éͧ¡Ñ¹ª×èÍÃÙ»«éÓ
$photo=$date."_img.".$lastname;
copy($fileupload, "../photo/".$photo); //¡êÍ»»ÕéÃÙ»ÀÒ¾ä»Âѧâ¾Åà´ÍÃì photo
$sql3="update product set prd_photo='$photo' where prd_id='$row[0]'";
$result3=mysql_db_query($db,$sql3);
}
unlink($fileupload);
}
echo "<h3>Add product already</h3>";
echo "<meta http-equiv='refresh' content='1 ;url=product_add.php'>" ;
//echo "<META http-equiv='product.php' content='RevealTrans (Duration=3, Transition=23)'>";
mysql_close();
?>
Code (PHP)
Product (show)
<?
session_start();
if($login_admin_true<>session_id())
{
header("Location: ../index.php");
exit();
}
include("../config.inc.php");
$sql="select * from product,device,model where device.dv_id=model.dv_id and model.md_id=product.md_id order by dv_name,md_name";
$result=mysql_db_query($db,$sql);
$number=mysql_num_rows($result);
$no=1;
$Per_Page =30;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_db_query($db,$sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if($Num_Rows=="0"){
echo "äÁèÁÕÊÔ¹¤éÒé ";
exit();
}
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>¨Ó¹Ç¹ $Page ÁÒ¡¡ÇèÒ $Num_Pages ÂѧäÁèÁÕ¢éͤÇÒÁ<b></center>";
$sql .= " LIMIT $Page_start , $Per_Page";
$result=mysql_db_query($db,$sql);
?>
<table width="100%" border="0" cellpadding="10" cellspacing="0"><tr height="2"><td align="left"><font size='3' face='MS Sans Serif, Tahoma, sans-serif'><b>
áÊ´§ÊÔ¹¤éÒ <?= 1+(($Page-1)*$Per_Page);?> ¶Ö§
<?if(($Page*$Per_Page)>$Num_Rows)
echo $Num_Rows;
else
echo $Page*$Per_Page;
?> ÃÒ¡ÒÃ
( ¨Ò¡ÊÔ¹¤éÒ·Ñé§ËÁ´ <?= $Num_Rows;?> ÃÒ¡Òà )</b></font></td><td align="right">
<!--ÃÇÁ·Ñé§ËÁ´ : <b>
<?//=$Num_Pages;?>
</b> ˹éÒ :-->
<?/* ÊÃéÒ§»ØèÁÂé͹¡ÅѺ */
if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page'><font size='2' face='MS Sans Serif, Tahoma, sans-serif'>[<<Back]</font></a>";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo "[<a href='$PHP_SELF?Page=$i'><font size='2' face='MS Sans Serif, Tahoma, sans-serif'>$i</font></a>]";
else
echo "<b> $i </b>";
}
/*ÊÃéÒ§»ØèÁà´Ô¹Ë¹éÒ */
if($Page!=$Num_Pages)
echo "<a href ='$PHP_SELF?Page=$Next_Page'><font size='2' face='MS Sans Serif, Tahoma, sans-serif'>[Next>>]</font> </a>";
echo "</td></tr></table>";
if($number<>0){
echo "
<table width='100% border='1'>
<tr bgcolor='#e8e8e8'>
<td align='center' width='6%'><b>Code Product</b></td>
<td align='center' width='42%'><b>Product</b></td>
<td align='center' width='12%'><b>category Product</b></td>
<td align='center' width='12%'><b>model Product</b></td>
<td align='center' width='8%'><b>Price</b></td>
<td align='center' width='8%'><b>Special Price</b></td>
<td align='center' width='7%'><b>[Edit]</b></td>
<td align='center' width='5%'><b>[Delete]</b></td>
</tr>";
while($rs=mysql_fetch_array($result)){
$prd_id=$rs[prd_id];
$prd_code=sprintf("%05d",$prd_id);
$prd_name=$rs[prd_name];
$dv_name=$rs[dv_name];
$md_id=$rs[md_id];
$md_name=$rs[md_name];
$prd_price=$rs[prd_price];
$sp_price=$rs[sp_price];
$prd_photo=$rs[prd_photo];
// $sql2="select type_name from type where type_id='$type_id'";
// $result2=mysql_db_query($db,$sql2);
// $rs2=mysql_fetch_array($result2);
// $type_name=$rs2[type_name];
if($no%2==0){
echo "<tr bgcolor=#F8F8FF>";
}else{
echo "<tr bgcolor=#FFF8DC>";
}
echo "
<td align='center'>$prd_code</td>
<td align='left'> $prd_name</td>
<td align='left'> $dv_name</td>
<td align='left'> $md_name</td>
<td align='right'>$prd_price.00 - </td>
<td align='right'>$sp_price.00 - </td>
<td align='center'><a href=\"product_edit.php?id_edit=$prd_id\">[á¡éä¢]</a></td>
<td align='center'><a href=\"product_delete.php?id_del=$prd_id&photo_del=$prd_photo\" onclick=\"return confirm('Confirm delete Category $prd_name Exit')\">[Delete]</a></td>
</tr>";
$no++;
}
echo "</table>";
mysql_close();
}
?>
<table width="100%" border="0" cellpadding="10" cellspacing="0"><tr height="2"><td align="left"><font size='3' face='MS Sans Serif, Tahoma, sans-serif'><b>
Show Product <?= 1+(($Page-1)*$Per_Page);?> ¶Ö§
<?if(($Page*$Per_Page)>$Num_Rows)
echo $Num_Rows;
else
echo $Page*$Per_Page;
?> List
( ¨Ò¡ÊÔ¹¤éÒ·Ñé§ËÁ´ <?= $Num_Rows;?> List )</b></font></td><td align="right">
<!--ÃÇÁ·Ñé§ËÁ´ : <b>
<?//=$Num_Pages;?>
</b> ˹éÒ :-->
<?/* ÊÃéÒ§»ØèÁÂé͹¡ÅѺ */
if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page'><font size='2' face='MS Sans Serif, Tahoma, sans-serif'>[<<Back]</font></a>";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo "[<a href='$PHP_SELF?Page=$i'><font size='2' face='MS Sans Serif, Tahoma, sans-serif'>$i</font></a>]";
else
echo "<b> $i </b>";
}
/*ÊÃéÒ§»ØèÁà´Ô¹Ë¹éÒ */
if($Page!=$Num_Pages)
echo "<a href ='$PHP_SELF?Page=$Next_Page'><font size='2' face='MS Sans Serif, Tahoma, sans-serif'>[Next>>]</font> </a>";
echo "</td></tr></table>";
data base ครับ
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2013-12-30 21:48:24 |
By :
patz8899 |
View :
766 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง echo $sql; ออกมาดูหน่อยครับ
|
|
|
|
|
Date :
2013-12-31 08:26:24 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM `product` WHERE 1
เป็น 0 เลยครับ
|
|
|
|
|
Date :
2013-12-31 09:03:57 |
By :
patz8899 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|