|
|
|
อัพเดทข้อความพร้อมรูปภาพไม่ได้ มันอัพเดทได้แต่รูปภาพ ลองหลายวิธีแล้วยังทำไม่ได้เลย ช่วยหน่อยนะค่ะ |
|
|
|
|
|
|
|
ลองดูโค๊ดนี้นะค่ะ อาจจะช่วยได้ เราสั่งให้มัน delete update insert ในหน้าเดียวกันเลย แต่คุณลองแกะโค๊ดดูละกันนะ หวังว่าจะช่วยได้นะค่ะ ลองก๊อปปี้แล้วไปอ่านดูที่ texteditor โชคดีนะค่ะ
Code (PHP)
<?
ob_start();
session_start();
if($_SESSION["adminlogin"]=="")
{
header('location:index.php');
exit();
}
//============ Start Session áÅзӡÒÃàÃÕ¡ Function µÔ´µèÍ°Ò¹¢éÍÁÙÅ
require_once('../connect/connect.php');
?>
<html>
<title>..:: Ãкº¨Ñ´¡Òðҹ¢éÍÁÙÅ ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link rel="stylesheet" href="../css/styles.css" type="text/css">
<div align="center"><br>
<table cellspacing=1 cellpadding=4 width="59%" bgcolor=#CCCCCC border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="100%" bgcolor="#FFFFFF"> <div align="center"></div>
<table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="35%" bgcolor="#FFFFFF"> <div align="left"><b><img src="../image/allrowto.gif" width="11" height="11" align="absbottom">
ËÁÇ´ÊÔ¹¤éÒ</b></div></td>
<td width="22%" align=middle bgcolor="#FFFFFF"> <div align="left">
</div></td>
<td width="43%" bgcolor="#FFFFFF"> <div align="right"><a href="head.php">¡ÅѺä»Ë¹éÒËÅÑ¡</a></div></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div>
<? //=========== ¡Ã³ÕÁÕ¡ÒÃá¡éä¢ËÁÇ´ÊÔ¹¤éÒ
if($_POST["update"]==True)
{
//=========== ºÑ¹·Ö¡¢éÍÁÙÅ
$sql_up = "update category set CategoryName='$_POST[txtCategoryName]',CheckStock='$_POST[txtCheck]' where CatID='$_POST[CatID]'";
//echo $sql_up ;
$dbquery_up = mysql_db_query($db, $sql_up);
//exit();
//=========== ¶éÒÁÕ¡ÒÃá¡éä¢ä¿Åì
if(!empty($file1))
{
$path="../picture";
@copy( $file1 ,"$path/$file1_name");
$sql_up = "update category set Picture='$file1_name' where CatID='$_POST[CatID]'";
$dbquery_up = mysql_db_query($db, $sql_up);
}
echo"<script language='JavaScript'>";
echo"alert('á¡é䢢éÍÁÙÅàÃÕºÃéÍÂáÅéÇ');";
echo"window.location='category.php';";
echo"</script>";
}
//=========== ¶éÒÁÕ¡ÒÃź¢éÍÁÙÅ
if($_GET["del"]==True)
{
//=========== źËÁÇ´
$sql_del= "delete from category where CatID='$_GET[CatID]'";
$dbquery_del = mysql_query($sql_del);
//=========== źÃÙ»ÀÒ¾
@unlink("../picture/$_GET[filename]");
echo"<script language='JavaScript'>";
echo"alert('ź¢éÍÁÙÅàÃÕºÃéÍÂáÅéÇ');";
echo"window.location='category.php';";
echo"</script>";
}
//=========== ¶éÒÁÕ¡ÒÃà¾ÔèÁËÁÇ´ËÁÇ´ãËÁè
if($_POST["add"]==True)
{
$path="../picture";
//=========== ÍѾâËŵÃÙ»ÀÒ¾
copy( $file1 , "$path/$file1_name" );
//=========== ºÑ¹·Ö¡¢éÍÁÙÅ
$sql = "insert into category(CategoryName,Picture) values ('$_POST[txtCategoryName]','$file1_name')";
$dbquery = mysql_query($sql);
echo"<script language='JavaScript'>";
echo"alert('à¾ÔèÁ¢éÍÁÙÅàÃÕºÃéÍÂáÅéÇ');";
echo"window.location='category.php';";
echo"</script>";
}
//=========== àÍÒ¢éÍÁØÅÁÒáÊ´§·Ñé§ËÁ´
$sql_group = "select * from category order by CatID asc";
$dbquery_group = mysql_query($sql_group);
$num_rows_group = mysql_num_rows($dbquery_group);
while ($result = mysql_fetch_array($dbquery_group))
{
?>
<form name="frm<?=$i;?>" method="post" action="<?=$_SERVER['PHP_SELF'];?>" enctype="multipart/form-data">
<table cellspacing=1 cellpadding=4 width="59%" bgcolor=#CCCCCC border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="104" bgcolor="#FFFFFF"> <div align="center"></div>
<table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="50" bgcolor="#FFFFFF">
<div align="center">
<input name="CatID" type="hidden" class="checkbox" id="CatID" value="<?=$result["CatID"]; ?>">
</div>
</td>
<td width="440" align=middle bgcolor="#FFFFFF">
<div align="left">
<input name="txtCategoryName" type="text" class="txtbox" id="txtCategoryName" value="<?=$result["CategoryName"]; ?>" size="50">
<br>
¨Ó¹Ç¹·Õèµéͧ¡ÒÃãËéáÊ´§àÁ×èÍÊÔ¹¤éÒã¡ÅéËÁ´
<input name="txtCheck" type="text" class="txtbox" id="txtCheck" value="<?=$result["CheckStock"]; ?>" size="10">
<input type="hidden" name="update" value="True">
<script language="JavaScript">
function Conf<?=$result["CatID"]; ?>(object) {
if (confirm("Â×¹Âѹ¡ÒÃźËÁÇ´ [ <?=$result["CategoryName"]; ?> ] ") ==true) {
return true;
}
return false;
}
</script>
</span><br>
<a href="product.php?CatID=<?=$result["CatID"];?>"><img src="../picture/<?=$result["Picture"]; ?>" width="60" height="60" border="0"></a>
<br>
á¡éä¢
<input type="file" name="file1" class="txtbox">
60*60<br>
<br>
<input type="submit" name="Submit" value="ºÑ¹·Ö¡¢éÍÁÙÅ" class="button">
<br>
</div>
</td>
<td width="48" bgcolor="#FFFFFF">
<div align="center"><a href="<?=$_SERVER['PHP_SELF'];?>?CatID=<?=$result["CatID"]; ?>&filename=<?=$result["Picture"]; ?>&del=True" onClick="return Conf<?=$result["CatID"]; ?>(this)"><img src="../image/delete.gif" width="16" height="16" border="0"></a></div>
</td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</form>
<?
$i++;
}
?>
<table cellspacing=1 cellpadding=4 width="59%" bgcolor=#9999FF border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="104" bgcolor="#FFFFFF">
<div align="center"><b>à¾ÔèÁËÁÇ´ÊÔ¹¤éÒ</b>
</div>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="frmAdd" id="frmAdd">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="11%"><input name="add" type="hidden" id="add" value="True"></td>
<td width="69%">
<input name="txtCategoryName" type="text" class="txtbox" id="txtCategoryName" value="ª×èÍËÁÇ´">
<br>
ä¿ÅìÃÙ»ÀÒ¾
<input type="file" name="file1" class="txtbox" size="20">
60*60 </td>
<td width="20%"> </td>
</tr>
<tr>
<td width="11%"> </td>
<td width="69%"> <br>
<input type="submit" name="Submit2" value="à¾ÔèÁ" class="button">
</td>
<td width="20%"> </td>
</tr>
</table>
</form>
</td>
</tr>
</tbody>
</table>
<table cellspacing=0 cellpadding=0 width="59%" bgcolor=#CCCCCC border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="100%" bgcolor="#FFFFFF"> <div align="center"></div>
<table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="35%" bgcolor="#FFFFFF"> <div align="left"></div></td>
<td width="22%" align=middle bgcolor="#FFFFFF"> <div align="left">
</div></td>
<td width="43%" bgcolor="#FFFFFF"> <div align="right"><a href="head.php">¡ÅѺä»Ë¹éÒËÅÑ¡</a></div></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
|
|
|
|
|
Date :
2011-12-03 16:23:33 |
By :
มือใหม่หัดขับ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากนะค่ะ
|
|
|
|
|
Date :
2011-12-03 16:25:06 |
By :
toon95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|