|
|
|
ช่วยดูโค๊ดหน่อยครับ สังเกตุที่ edit_design.php นะครับ ผมพยายามทำให้มันเข้าเงื่อนไขอื่น ที่ไม่ใช่เงื่อนไขที่ 4 แต่มันไม่ยอมเปลี่ยนไปไหนเลยครับ |
|
|
|
|
|
|
|
edit_design_form.php(PHP)
<?
session_start();
if(empty($username))
{ header('location:admin_form.php'); exit(); }
require_once("include/connect_db.php");
require_once("include/function.php");
require_once("include/check_data.php");
$result = select_book($ID_PRODUCT);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$catego=$row["ID_CATEGORIES"];
$O = $row["PICTURE_SMALL"];
$OO = $row["PICTURE_BIG"];
?>
<table align="center" width="500">
<form action="edit_design.php" method="post" enctype="multipart/form-data">
<tr>
<td bgcolor="#AACCCC"><font face="MS Sans serif"><b>ID</b></font><font face="Ms Sans serif"><b> : </b></font></td>
<td bgcolor="#DDEEEE" colspan="2"><input type="text" value="<?=$row["ID_PRODUCT"]?>" name="ID_PRODUCT">
<input type="hidden" name="oldisbn" value="<?=$row["ID_PRODUCT"]?>">
</td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font face="MS Sans serif"><b>SIZE</b></font><font face="Ms Sans serif"><b> : </b></font></td>
<td bgcolor="#DDEEEE" colspan="2"><input type="text" value="<?=$row["SIZE"]?>" name="SIZE" maxlength="60" size="40">
mm. </td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font face="MS Sans serif"><b>PRICE</b></font><font face="Ms Sans serif"><b> : </b></font></td>
<td bgcolor="#DDEEEE" colspan="2"><input type="text" value="<?=$row["PRICE"]?>" maxlength="100" size ="30" name="PRICE"></td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font face="MS Sans serif"><b>PICTURE_SMALL : </b></font></td>
<td bgcolor="#DDEEEE"><input type="file" name="PICTURE_SMALL" value="<?=$row["PICTURE_SMALL"];?>" ></td>
<td bgcolor="#DDEEEE"><img src="<?=$row["PICTURE_SMALL"] ;?>" ></td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font face="MS Sans serif"><b>PICTURE_BIG : </b></font></td>
<td bgcolor="#DDEEEE"><input type="file" name="PICTURE_BIG" value="<?=$row["PICTURE_BIG"];?>"></td>
<td bgcolor="#DDEEEE"><img src="<?=$row["PICTURE_BIG"];?>" ></td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font face="Ms Sans serif"><b>หมวดหมู่ : </b></font></td>
<td bgcolor="#DDEEEE" colspan="2"><select size="1" name="ID_CATEGORIES">
<?
$con=connect_db("ksnasia");
$sql = "select * from categories order by CATEGORIES_NAME;";
$resultcat = mysql_query($sql);
while($cate = mysql_fetch_array($resultcat,MYSQL_ASSOC))
{
if($row["ID_CATEGORIES"]==$cate["ID_CATEGORIES"])
echo "<option value=". $cate["ID_CATEGORIES"] ." selected>".$cate["CATEGORIES_NAME"]."</option>";
else
echo "<option value= ".$cate["ID_CATEGORIES"].">".$cate["CATEGORIES_NAME"]."</option>";
}
?>
</td>
</tr>
<tr><td align="center">
<input type="hidden" value="<?="$O"?>" name="O">
<input type="hidden" value="<?="$OO"?>" name="OO">
<input type="submit" name="edit" value="edit design"></td>
</form>
<form action="delete_design.php" method="post">
<td align="center">
<input type="hidden" value="<?=$row["ID_PRODUCT"]?>" name="ID_PRODUCT">
<input type="hidden" value="<?=$row["PICTURE_SMALL"]?>" name="PICTURE_SMALL">
<input type="hidden" value="<?=$row["PICTURE_BIG"]?>" name="PICTURE_BIG">
<input type="submit" name="delete" value="delete design"></td>
</form>
<form action="showdata.php" method="post">
<?
$Message = "";
?>
<input type="hidden" value="<? $Message ?>" name="Message">
<td align="center"><input type="submit" name="Back" value="Back">
</form>
</table>
edit_design.php(PHP)
<?
require_once("include/check_data.php");
require_once("include/connect_db.php");
require_once("include/function.php");
session_start();
if($_REQUEST['edit']){
if(!$PICTURE_SMALL & !$PICTURE_BIG) //เงื่อนไขไม่ได้แก้รูปภาพ
$con=connect_db("#####"); //ติดต่อฐานข้อมูล
$sql = "update product set SIZE = '$SIZE' , PRICE = '$PRICE' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';"; //ตารางข้อมูล
$result = mysql_query($sql);
if($result)
{
session_register("error");
session_register("user");
//$error = "Insert Design Successfully";
$error = "1";
header("location:showdata.php");
}
if (!$PICTURE_SMALL & $PICTURE_BIG) //เงื่อนไขไม่ได้แก้รูปภาพเล็ก
//ลบรูปเก่า
unlink("$OO");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture_big=$_FILES["PICTURE_BIG"]["tmp_name"];
$filename_big=$_FILES["PICTURE_BIG"]["name"];
$path="image/$SSS/";
$image_big=$path.$filename_big;
$copied2=copy($picture_big,$image_big);
$sql = "update product set SIZE='$SIZE',PRICE='$PRICE' , PICTURE_SMALL = '$image' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("error");
session_register("user");
//$error = "Insert Design Successfully";
$error = "2";
header("location:showdata.php");
}
if ($PICTURE_SMALL & !$PICTURE_BIG) //เงื่อนไขไม่ได้แก้รูปภาพใหญ่
//ลบรูปเก่า
unlink("$O");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture=$_FILES["PICTURE_SMALL"]["tmp_name"];
$filename=$_FILES["PICTURE_SMALL"]["name"];
$path="image/$SSS/";
$image=$path.$filename;
$copied1=copy($picture,$image);
$sql = "update product set SIZE='$SIZE',PRICE='$PRICE' , PICTURE_BIG='$image_big' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("error");
session_register("user");
//$error = "Insert Design Successfully";
$error = "3";
header("location:showdata.php");
}
if ($PICTURE_SMALL and $PICTURE_BIG) //เงื่อนไขแก้รูปภาพทั้งสองรูป
//ลบรูปเก่า
unlink("$O");
unlink("$OO");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture=$_FILES["PICTURE_SMALL"]["tmp_name"];
$filename=$_FILES["PICTURE_SMALL"]["name"];
$picture_big=$_FILES["PICTURE_BIG"]["tmp_name"];
$filename_big=$_FILES["PICTURE_BIG"]["name"];
$path="image/$SSS/";
$image=$path.$filename;
$image_big=$path.$filename_big;
$copied1=copy($picture,$image);
$copied2=copy($picture_big,$image_big);
$sql = "update product set SIZE = '$SIZE' , PRICE = '$PRICE' , PICTURE_SMALL = '$image' , PICTURE_BIG='$image_big' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("Message");
session_register("user");
$Message = "4";
header("location:showdata.php");
}
}
?>
สังเกตุที่ edit_design.php นะครับ
ผมพยายามทำให้มันเข้าเงื่อนไขอื่น ที่ไม่ใช่เงื่อนไขที่ 4 แต่มันไม่ยอมเปลี่ยนไปไหนเลยครับ
ใครใจบุญช่วยดูหน่อยครับ
Tag : - - - -
|
|
|
|
|
|
Date :
2010-02-17 15:30:18 |
By :
kitkunpai |
View :
898 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วไม่ใช่
if(){
}
else if(){
}
else{
}
ละคับ ใช้ if หมดมันก็ติดอยู่แล้วละคับ เพราะมันทำทุกเงื่อนไขเลย
|
|
|
|
|
Date :
2010-02-17 17:04:16 |
By :
Po[k]@za |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
require_once("include/check_data.php");
require_once("include/connect_db.php");
require_once("include/function.php");
session_start();
if($_REQUEST['edit'])
{
if(!$PICTURE_SMALL & !$PICTURE_BIG) //เงื่อนไขไม่ได้แก้รูปภาพ
{
$con=connect_db("####"); //ติดต่อฐานข้อมูล
$sql = "update product set SIZE = '$SIZE' , PRICE = '$PRICE' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';"; //ตารางข้อมูล
$result = mysql_query($sql);
if($result)
{
session_register("Message");
session_register("user");
//$error = "Insert Design Successfully";
$Message = "1";
header("location:showdata.php");
}
}
else if (!$PICTURE_SMALL & $PICTURE_BIG) //เงื่อนไขไม่ได้แก้รูปภาพเล็ก
{ //ลบรูปเก่า
unlink("$OO");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture_big=$_FILES["PICTURE_BIG"]["tmp_name"];
$filename_big=$_FILES["PICTURE_BIG"]["name"];
$path="image/$SSS/";
$image_big=$path.$filename_big;
$copied2=copy($picture_big,$image_big);
$sql = "update product set SIZE='$SIZE',PRICE='$PRICE' , PICTURE_SMALL = '$image' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("Message");
session_register("user");
//$error = "Insert Design Successfully";
$Message = "2";
header("location:showdata.php");
}
}
else if ($PICTURE_SMALL & !$PICTURE_BIG) //เงื่อนไขไม่ได้แก้รูปภาพใหญ่
{ //ลบรูปเก่า
unlink("$O");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture=$_FILES["PICTURE_SMALL"]["tmp_name"];
$filename=$_FILES["PICTURE_SMALL"]["name"];
$path="image/$SSS/";
$image=$path.$filename;
$copied1=copy($picture,$image);
$sql = "update product set SIZE='$SIZE',PRICE='$PRICE' , PICTURE_BIG='$image_big' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("Message");
session_register("user");
//$error = "Insert Design Successfully";
$Message = "3";
header("location:showdata.php");
}
}
else//เงื่อนไขแก้รูปภาพทั้งสองรูป
{
//ลบรูปเก่า
unlink("$O");
unlink("$OO");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture=$_FILES["PICTURE_SMALL"]["tmp_name"];
$filename=$_FILES["PICTURE_SMALL"]["name"];
$picture_big=$_FILES["PICTURE_BIG"]["tmp_name"];
$filename_big=$_FILES["PICTURE_BIG"]["name"];
$path="image/$SSS/";
$image=$path.$filename;
$image_big=$path.$filename_big;
$copied1=copy($picture,$image);
$copied2=copy($picture_big,$image_big);
$sql = "update product set SIZE = '$SIZE' , PRICE = '$PRICE' , PICTURE_SMALL = '$image' , PICTURE_BIG='$image_big' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("Message");
session_register("user");
$Message = "4";
header("location:showdata.php");
}
}
}
?>
ตอนนี้เข้า เงื่อนไขที่ 1 กับ 4 ได้แล้วครับ
เหลือ 2 กับ 3 แก้ยังไงดีครับ
|
|
|
|
|
Date :
2010-02-18 14:26:19 |
By :
kitkunpai |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
require_once("include/check_data.php");
require_once("include/connect_db.php");
require_once("include/function.php");
session_start();
if($_REQUEST['edit'])
{
if(!$PICTURE_SMALL and !$PICTURE_BIG) //เงื่อนไขไม่ได้แก้รูปภาพ
{
$con=connect_db("####"); //ติดต่อฐานข้อมูล
$sql = "update product set SIZE = '$SIZE' , PRICE = '$PRICE' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';"; //ตารางข้อมูล
$result = mysql_query($sql);
if($result)
{
session_register("Message");
//$error = "Insert Design Successfully";
$Message = "1";
header("location:showdata.php");
exit();
}
}
elseif(!$PICTURE_SMALL) //เงื่อนไขแก้ไขรูปภาพใหญ่
{ //ลบรูปเก่า
unlink("$OO");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture_big=$_FILES["PICTURE_BIG"]["tmp_name"];
$filename_big=$_FILES["PICTURE_BIG"]["name"];
$path="image/$SSS/";
$image_big=$path.$filename_big;
$copied2=copy($picture_big,$image_big);
$sql = "update product set SIZE='$SIZE',PRICE='$PRICE' , PICTURE_BIG = '$image_big' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("Message");
//$error = "Insert Design Successfully";
$Message = "2";
header("location:showdata.php");
exit();
}
}
elseif(!$PICTURE_BIG) //เงื่อนไขแก้ไขรูปภาพเล็ก
{ //ลบรูปเก่า
unlink("$O");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture=$_FILES["PICTURE_SMALL"]["tmp_name"];
$filename=$_FILES["PICTURE_SMALL"]["name"];
$path="image/$SSS/";
$image=$path.$filename;
$copied1=copy($picture,$image);
$sql = "update product set SIZE='$SIZE',PRICE='$PRICE' , PICTURE_SMALL='$image' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("Message");
//$error = "Insert Design Successfully";
$Message = "3";
header("location:showdata.php");
exit();
}
}
else //เงื่อนไขแก้รูปภาพทั้งสองรูป
{
//ลบรูปเก่า
unlink("$O");
unlink("$OO");
//เพิ่มรูปใหม่
$result = select_path("$ID_CATEGORIES");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$SSS = $row["CATEGORIES_NAME"];
$picture=$_FILES["PICTURE_SMALL"]["tmp_name"];
$filename=$_FILES["PICTURE_SMALL"]["name"];
$picture_big=$_FILES["PICTURE_BIG"]["tmp_name"];
$filename_big=$_FILES["PICTURE_BIG"]["name"];
$path="image/$SSS/";
$image=$path.$filename;
$image_big=$path.$filename_big;
$copied1=copy($picture,$image);
$copied2=copy($picture_big,$image_big);
$sql = "update product set SIZE = '$SIZE' , PRICE = '$PRICE' , PICTURE_SMALL = '$image' , PICTURE_BIG='$image_big' , ID_CATEGORIES = '$ID_CATEGORIES' where ID_PRODUCT='$ID_PRODUCT';";
$result = mysql_query($sql);
if($result)
{
session_register("Message");
session_register("user");
$Message = "4";
header("location:showdata.php");
exit();
}
}
}
?>
แก้ได้แล้วนะครับ ขอบคุณทุกท่านที่ผ่านเข้ามาชมครับ
|
|
|
|
|
Date :
2010-02-18 15:11:21 |
By :
kitkunpai |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|