|
|
|
ช่วยดู การอัพรูปของโค้ดแก้ ไขนี้ที ทำการแก้ไขรูปแล้ว ชื้อรูปในฐานข้อมูล เป็น .tmp |
|
|
|
|
|
|
|
Code (PHP)
<?php
session_start() ;
if(!session_is_registered("login_true_admin")) {
echo "<meta http-equiv=refresh content=2;url=index.php>" ;
exit() ;
}
?>
<html>
<head>
<title>แก้ไขข้อมูลสินค้า</title>
<META content="text/html; charset=windows-874" http-equiv=Content-Type>
<LINK href="textstyle.css" rel=stylesheet></head>
<body aLink=#000000 bgColor=white leftMargin=0 link=#000000 text=#000000
topMargin=0 vLink=#000000 marginheight="0" marginwidth="0">
<div align="center">
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<?php include("header.php"); ?>
</td>
</tr>
</table>
<table width="780" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td width="180" height="284" valign="top" bgcolor="#FFCCFF">
<?php include("menua.php"); ?>
</td>
<td width="625" align="center" valign="top" bgcolor="#FFCCFF"><table width="100%" border="1" bordercolor="#FFCCFF" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td align="center" valign="top" bgcolor="#FFFFFF">
<TABLE cellSpacing=0 cellPadding=0 width="550" border=0>
<TBODY>
<TR>
<TD width="620" class=main></TD>
</TR>
<TR>
<TD height="742" valign="top"> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
</TABLE>
<TABLE width="100%"
border=0 cellPadding=1 cellSpacing=0 bgcolor="#FCFCFC" class=infoBox>
<TBODY>
<TR>
<TD height="720" align="center" valign="top" bgcolor="#FCFCFC" class="smallx">
<? if(!$Submit) {?>
<?
include "../config.php";
$sql="select * from product where pro_id='$idu'";
$result= mysql_query($sql);
$row=mysql_fetch_array($result);
$proid=$row['pro_id'];
$catid=$row['cat_id'];
$proname=$row['pro_name'];
$proprice=$row['pro_price'];
$file=$row['pro_image'];
$prodetail=$row['pro_detail'];
$prosize=$row['pro_size'];
$proweight=$row['pro_weight'];
$procolor=$row['pro_color'];
$pronum=$row['amountsale'];
?><br>
<div align="center">
<div align="center"> <strong>
<p align="center"><strong><font color="#000099" size="2">แก้ไขข้อมูลสินค้า</font></strong></p>
<form name="checkForm" method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF ?>" onSubmit="return check()"><div align="left">
<div align="left">
<table width="91%" height="530" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFCCFF">
<tr>
<td height="528" valign="top" bgcolor="#CCCCCC"><TABLE width=100% border=0 align="center" cellpadding="1" cellspacing="0" bgcolor="#ffffcc" class=text>
<TBODY>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD colspan="3" align=right vAlign=center><div align="center"><font color="#FF0099" size="2"><strong>ข้อมูลสินค้า</strong></font></div></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD width="77" align=right vAlign=center><font size="2"> </font></TD>
<TD width="10" align=right vAlign=center><div align="center"><font size="2"></font></div></TD>
<TD width="340" align=left vAlign=center><font size="2"> </font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=center><font size="2">รหัสสินค้า</font></TD>
<TD align=right vAlign=center><div align="center">:</div></TD>
<TD align=left vAlign=center><font size="2"><?php echo "$proid"?></font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=center><font size="2">ประเภทสินค้า</font></TD>
<TD align=right vAlign=center><div align="center"><font size="2">:</font></div></TD>
<TD align=left vAlign=center>
<font size="2">
<select size="1" name="type">
<?
$i=0;
$type_result=mysql_db_query($dbname,"select cat_id,cat_name from category order by cat_id");
while (list($cat_id,$cat_name)=mysql_fetch_row($type_result)){ $i ++;
if($row[1]==$cat_id){?>
<option value="<?=$cat_id;?>" selected>
<?echo $i;?> -
<?=$cat_name;?>
</option>
<?
}else{
?>
<option value="<?=$cat_id;?>">
<?echo $i;?> -
<?=$cat_name;?>
</option>
<?}?>
<?}?>
</select>
</font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=center><font size="2" >ชื่อสินค้า</font></TD>
<TD align=right vAlign=center><div align="center"><font size="2">:</font></div></TD>
<TD align=left vAlign=center><font size="2"><strong>
<input name="proname" type="text" id="proname" size="40" value="<?php echo "$proname"?>">
</strong> <font color="#FF0000">
</font></font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=center><font size="2">ราคา/หน่วย</font></TD>
<TD align=right vAlign=center><div align="center"><font size="2">:</font></div></TD>
<TD> <font size="2"><strong>
<input name="proprice" type="text" id="proprice" size="15" value="<?php echo number_format($proprice,2) ?>">
</strong>บาท <strong> </strong></font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=top><font size="2">ไฟล์รูปสินค้าเดิม</font></TD>
<TD align=right vAlign=top><div align="center">:</div></TD>
<TD><font size="2"><img border="0" src="../product/<?=$file;?>" width="50" height="60"> ชื่อไฟล์
<?=$file ?>
</font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=top><font size="2">แก้ไขเป็นรูปสินค้า</font></TD>
<TD align=right vAlign=top><div align="center">:</div></TD>
<TD><label>
<input name="efile" type="file" id="efile" value="" size="26">
</label>
<label></label></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=top><font size="2">รายละเอียด</font></TD>
<TD align=right vAlign=top><div align="center"><font size="2">:</font></div></TD>
<TD> <font size="2"><strong>
<textarea rows="5" name="prodetail" cols="40"><?=$prodetail?> </textarea>
</strong></font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=center><font size="2">ขนาด</font></TD>
<TD align=right vAlign=center><div align="center"><font size="2">:</font></div></TD>
<TD><font size="2"><strong>
<input name="prosize" type="text" id="prosize" size="15" value="<?php echo "$prosize"?>">
</strong>นิ้ว </font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=center><font size="2">น้ำหนัก/ชิ้น</font></TD>
<TD align=right vAlign=center><div align="center"><font size="2">:</font></div></TD>
<TD> <font size="2"><strong>
<input name="proweight" type="text" id="proweight" size="15" value="<?php echo "$proweight"?>">
</strong>กรัม</font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=center><font size="2">สี</font></TD>
<TD align=right vAlign=center><div align="center"><font size="2">:</font></div></TD>
<TD><font size="2"><strong>
<input name="procolor" type="text" id="procolor" size="15" value="<?php echo "$procolor"?>">
</strong></font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD align=right vAlign=center><font size="2">จำนวน</font></TD>
<TD align=right vAlign=center><div align="center"><font size="2">:</font></div></TD>
<TD><font size="2"><strong>
<input name="pronum" type="text" id="pronum" size="15" value="<?php echo "$pronum"?>">
</strong>ชิ้น</font></TD>
</TR>
<TR bordercolor="#ffffcc" bgcolor="#CCCCCC">
<TD height="22" colspan="3" align=right vAlign=center><font size="2"> </font> <div align="center">
<p><font size="2"></font></p>
<p> </p>
</div> <div align="center"><font size="2">
<input type="submit" value=" แก้ไข " name="Submit">
</font></div></TD>
</TR>
</TBODY>
</TABLE>
<div align="center"></div></td>
</tr>
</table>
<p align="center">
<script language="JavaScript">
function check() {
if(document.checkForm.type.value=="") {
alert("กรุณาเสือกประเภทสินค้าด้วยครับ") ;
document.checkForm.type.focus() ;
return false ;
}
else if(document.checkForm.proname.value=="") {
alert("กรุณากรอกชื่อสินค้าด้วยครับ") ;
document.checkForm.proname.focus() ;
return false ;
}
else if(document.checkForm.proprice.value=="") {
alert("กรุณากรอกราคาสินค้าด้วยครับ") ;
document.checkForm.proprice.focus() ;
return false ;
}
else if(isNaN(document.checkForm.proprice.value)) {
document.checkForm.proprice.value="";
alert("ราคาสินค้าต้องเป็นตัวเลขครับ") ;
document.checkForm.proprice.focus() ;
return false ;
}
else if(document.checkForm.prodetail.value=="") {
alert("กรุณากรอกรายละเอียดด้วยครับ") ;
document.checkForm.prodetail.focus() ;
return false ;
}
else if(document.checkForm.prosize.value=="") {
alert("กรุณากรอกขนาดด้วยครับ") ;
document.checkForm.prosize.focus() ;
return false ;
}
else if(document.checkForm.proweight.value=="") {
alert("กรุณากรอกน้ำหนักสินค้าด้วยครับ") ;
document.checkForm.proweight.focus() ;
return false ;
}
else if(isNaN(document.checkForm.proweight.value)) {
document.checkForm.proweight.value="";
alert("น้ำหนักสินค้าต้องเป็นตัวเลขครับ") ;
document.checkForm.proweight.focus() ;
return false ;
}
else if(document.checkForm.procolor.value=="") {
alert("กรุณากรอกสีของสินค้าด้วยครับ") ;
document.checkForm.procolor.focus() ;
return false ;
}
else if(document.checkForm.pronum.value=="") {
alert("กรุณากรอกจำนวนสินค้าด้วยครับ") ;
document.checkForm.pronum.focus() ;
return false ;
}
else if(isNaN(document.checkForm.pronum.value)) {
document.checkForm.pronum.value="";
alert("จำนวนสินค้าต้องเป็นตัวเลขครับ") ;
document.checkForm.pronum.focus() ;
return false ;
}
else
return true ;
}
</script>
<input name="idu" type="hidden" value="<? echo $proid?>">
<font color="#0000FF" face="MS Sans Serif, Tahoma, sans-serif"><strong>
</strong></font> <strong><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">
</font></strong><strong><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">
</font></strong></div>
</form>
<p> <? }else{ // $file=$row['pro_image'];
include "../config.php";
if($efile =="") {$efile = $file;}
echo " 1 : ",$type;
echo "<br> 2 : ",$proname;
echo "<br> 3 : ",$idu;
echo "<br> ",
$sql="UPDATE product SET cat_id= '$type', pro_name= '$proname', pro_price= '$proprice', pro_image='$efile', amountstock= '$pronum', pro_detail='$prodetail', pro_size= '$prosize', pro_weight= '$proweight', pro_color= '$procolor' WHERE pro_id='$idu' ";
//$sql="UPDATE product SET cat_id= '$type', pro_name= '$proname', pro_price= '$proprice', pro_image='$efile', amountstock= '$pronum', amountsale= '$pronum', pro_detail='$prodetail', pro_size= '$prosize', pro_weight= '$proweight', pro_color= '$procolor' WHERE pro_id='$idu' ";
$result= mysql_query($sql);
if ($result) {
echo"<br><b>แก้ไขข้อมูลสินค้าได้แล้ว</b>"; }
else {
echo"<br><b>แก้ไขข้อมูลสินค้าไม่ได้</b>";
}
echo "<meta http-equiv='refresh' content='3; url=show_pro.php'>" ; }
?></p>
</strong></div>
</div>
<div align="center">
<p>
<?
include "../config.php";
$sql="select * from product";
$result=mysql_query($sql);
$per_page=20;
if(!isset($page))
$page=1;
$prev_page=$page-1;
$next_page=$page+1;
$result=mysql_query($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 ( ( $page > $num_pages ) || ( $page < 0 ) )
print "จำนวน $page มากกว่า $num_pages";
$sql .= " LIMIT $page_start, $per_page";
$result = mysql_query( $sql );
?>
</p>
<div align="left">
<div align="center">
<p><strong><font size="2" color="#000033">ข้อมูลสินค้า </font></strong></p>
<table width="84%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<tr bgcolor="#FF99CC">
<td width="11%" ><div align="center"><strong><font color="#000000">ลำดับ</font></strong></div></td>
<td width="45%"><div align="center"><strong><font color="#000000">ชื่อสินค้า</font></strong></div></td>
<td width="11%"><div align="center"><strong><font color="#000000">ราคา</font></strong></div></td>
<td width="15%"><div align="center"><strong><font color="#000000">จำนวนคงเหลือ</font></strong></div></td>
<?
if($result)
{
while($row=mysql_fetch_array($result))
{
$a++;
$proid=$row['pro_id'];
$proname=$row['pro_name'];
$proprice=$row['pro_price'];
$amount=$row['amountsale'];
?>
<tr bgcolor="#FFDDFF">
<td height="20"><div align="center"><?=$a;?></div></td>
<td><?php echo $proname ?></td>
<td><p align="right"><?php echo number_format($proprice,2) ?></p></td>
<td><p align="right"><?php echo $amount ?></p></td>
</tr>
<?
}
}
?>
</table>
<p align="center"> <font size=2>รวมทั้งหมด
<b><?php echo $num_rows; ?></b> รายการ <b><?php echo $num_pages; ?></b>
หน้า : </font>
<?php
/* สร้างปุ่มย้อนกลับ */
if ( $prev_page )
echo "<a href=\"$PHP_SELF?page=$prev_page\"><< ถอยหลัง </a>";
/* สร้างตัวเลขหน้า */
for ( $i=1; $i<=$num_pages; $i++ )
{
if ( $i != $page )
echo "[<a href=\"$PHP_SELF?page=$i\">$i</a>]";
else
echo " <font color = red> <b>$i</b></font> ";
}
/* สร้างปุ่มเดินหน้า */
if ( $page != $num_pages )
echo "<a href=\"$PHP_SELF?page=$next_page\"> เดินหน้า >></a>";
mysql_close( $conn );
?>
</p>
<p> </p>
</div>
</div>
<p><strong> </strong></p>
</div>
</td>
</table>
</TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
</TBODY>
</TABLE></td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
<table width="778" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<?php include("../foot.php"); ?>
</td>
</tr>
</table>
</div>
</body>
</html>
ผลที่แสดงในตารางหลังการอัพเดท ชื่อรูปเป็น .tmp งง
Tag : PHP, JavaScript
|
|
|
|
|
|
Date :
2011-09-19 17:02:44 |
By :
tormam |
View :
985 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เห็นแล้วขี้เกียจจะดูเลย รบกวนเอาเฉพาะส่วนที่สำคัญ ๆ มาได้ป่าวครับตาลาย
|
|
|
|
|
Date :
2011-09-19 17:56:04 |
By :
treza |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|