อัพเดทข้อมูลแล้วรูปไม่ได้อัพเดท ข้อมูลอยู่ในรูปหายไป

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderators: mindphp, ผู้ดูแลกระดาน

mostgirls

อัพเดทข้อมูลแล้วรูปไม่ได้อัพเดท ข้อมูลอยู่ในรูปหายไป

Post by mostgirls »

Code: Select all

<?
session_start();
require_once "../config.php";
require_once "authen.php";
require_once CLASS_BASE."../class/main.class.php";
require_once("headeradmin.php");
?>

<?
//session_start();
require_once("include/connect_db.php");
require_once("include/function.php");
//require_once("headeradmin.php");
//require_once("include/check_data.php");
//header_admin("แก้ไขนาฬิกา");
//check_admin();
$result = select_book($isbn);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$catego=$row["catid"];
?>
<table width="500" border="1" align="center" bordercolor="#66AA99">
<form action="editwatch.php" method="post" enctype="multipart/form-data">
<tr>
  <td colspan="3" bgcolor="#33AAAA"><div align="center"><font face="MS Sans Serif" size="4" color="#FFFFFF"><b>แก้ไขนาฬิกา</b></font></div></td>
  </tr>
<tr>
  <td bgcolor="#AACCCC">&nbsp;</td>
  <td width="105" colspan="2" bgcolor="#DDEEEE">&nbsp;</td>
</tr>
<tr>
<td width="127" bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><b>Product Code : </b></font></td>
<td bgcolor="#DDEEEE" colspan="2"><input name="isbn" type="text" value="<?=$row["isbn"]?>" size="20" maxlength="13" readonly>
<input type="hidden" name="isbn" value="<?=$row["isbn"]?>"></td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><b>Title : </b></font></td>
<td bgcolor="#DDEEEE" colspan="2"><input type="text" value="<?=$row["title"]?>" name="title" maxlength="60" size="30"></td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><b>Graphician : </b></font></td>
<td bgcolor="#DDEEEE" colspan="2"><input type="text" value="<?=$row["author"]?>" maxlength="60" size ="30" name="author"></td>
</tr>

<tr>
<td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><b>Categories : </b></font></td>
<td bgcolor="#DDEEEE" colspan="2"><select size="1" name="catid">
<?
$resultcat = show_data("categories");
 while($cate = mysql_fetch_array($resultcat,MYSQL_ASSOC))
 {
     if($row["catid"]==$cate["catid"])
  echo "<option value=". $cate["catid"] ." selected>".$cate["catname"]."</option>";
    else
     echo "<option value= ".$cate["catid"].">".$cate["catname"]."</option>";
     }
?>
</select></td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><strong>Size : </strong></font></td>
<td bgcolor="#DDEEEE" colspan="2"><select name="page" id="page">
<?php 
    if($row["page"]=='40'){
?>
    <option value="40">JUMBO</option>    
    <option value="34">BOY-SIZE</option>
<?    
    }
    elseif($row["page"]==34){
?>    
    <option value="34">BOY-SIZE</option>
    <option value="40">JUMBO</option>
<?
    }
?>
</select>
   <font face="Ms Sans serif">&nbsp;</font><font size="2" face="MS Sans Serif"><b>mm.</b> </font></td>
</tr>
<tr>
  <td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><strong>Case : </strong></font></td>
  <td bgcolor="#DDEEEE" colspan="2"><input name="case_color" type="text" id="case_color" value="<?=$row["case_color"]?>" size="30" maxlength="60" /></td>
</tr>
<tr>
  <td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><strong>Buckle : </strong></font></td>
  <td bgcolor="#DDEEEE" colspan="2"><input name="buckle_color" type="text" id="buckle_color" value="<?=$row["buckle_color"]?>" size="30" maxlength="60" /></td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><strong>Status : </strong></font></td>
<td bgcolor="#DDEEEE" colspan="2">    <select name="publisher" id="publisher" >
 <?
    if($row["publisher"]=='NEW'){
 ?>
    <option value="NEW">NEW</option>
    <option value="HOT">HOT</option>
    <option value="PROMOTION">PROMOTION</option>
    <option selected="BLANK">BLANK</option>
 <?
    }
    elseif($row["publisher"]=='HOT'){
?>
    <option value="HOT">HOT</option>
    <option value="PROMOTION">PROMOTION</option>
    <option value="NEW">NEW</option>
    <option selected="BLANK">BLANK</option>
    <?
    }
    elseif($row["publisher"]=='BLANK'){
?>
     <option selected="BLANK">BLANK</option>
    <option value="HOT">HOT</option>
    <option value="PROMOTION">PROMOTION</option>
    <option value="NEW">NEW</option>
<?
    }
    elseif($row["publisher"]=='PROMOTION'){
?>
    <option value="PROMOTION">PROMOTION</option>
    <option value="NEW">NEW</option>
    <option value="HOT">HOT</option>
    <option selected="BLANK">BLANK</option>
<?
    }
 ?>
   </select></td>
</tr>
<!-- <tr>
<td bgcolor="#AACCCC"><strong>ความกว้างตัวเรือน </strong>  : </td>
<td bgcolor="#DDEEEE" colspan="2"><input type="text" name="time" maxlength ="10" size="10" value="<?=$row["time"]?>"></td>
</tr> -->
<tr>
<td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><strong>US : </strong></font></td>
<td bgcolor="#DDEEEE" colspan="2"><input type="text" name="price" maxlength ="5" size="7" value="<?=$row["price"]?>">
  <font size="2" face="MS Sans Serif"> <strong><font size="3">$</font></strong></font><font face="MS Sans serif">&nbsp;</font></td>
</tr>
<tr>
  <td colspan="3" bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><b>Description</b></font></td>
  </tr>
<tr>
  <td bgcolor="#AACCCC"><font color="#000000" size="2" face="Trebuchet MS"><strong>Package   :</strong></font></td>
  <td bgcolor="#DDEEEE" colspan="2"><select name="package" id="package">
    <?
    if($row["package"]=='BOY-SIZE'){
    ?>
    <option value="BOY-SIZE">BOY-SIZE</option>
    <option value="JUMBO">JUMBO</option>
    <?
}
    elseif($row["package"]=='JUMBO'){
    ?>
    <option value="JUMBO">JUMBO</option>
    <option value="BOY-SIZE">BOY-SIZE</option>
  <?
    }
?>
  </select></td>
</tr>
<tr>
  <td bgcolor="#AACCCC"><font color="#000000" size="2" face="Trebuchet MS"><strong>Balance   :</strong></font></td>
  <td bgcolor="#DDEEEE" colspan="2"><input type="text" name="balance" value="<?php echo $row["balance"];?>"></td>
</tr>
<tr>
<td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><b>Image 1 :</b></font></td>
<td width="246" bgcolor="#DDEEEE"><input type="file" name="fileUpload[]" size="25"  ></td>
<td width="105" bgcolor="#DDEEEE"><div align="center"><font size="2" face="Trebuchet MS"><img src="<?php echo "MyResize/";echo $row["picture"]?>" width="92" height="200" border ="1" /></font></div></td>
</tr>
<tr>
  <td bgcolor="#AACCCC"><font size="2" face="Trebuchet MS"><b>Image 2 : </b></font></td>
  <td bgcolor="#DDEEEE" colspan="1"><input type="file" name="fileUpload[]" size="25"></td>
  <td width="105" bgcolor="#DDEEEE"><div align="center"><font size="2" face="Trebuchet MS"><img src="<?php echo "MyResize/";echo $row["picture_2"]?>" width="92" height="200" border ="1" /></font></div></td>
</tr>
<tr><td align="center" colspan="3">
<input type="hidden" name="date" id="date" value="<?php echo $date; ?>"><input  type="submit" name="edit" value="แก้ไขนาฬิกา"></td>
</form>
<form action="deletewatch.php" method="post">
<td align="left">
<input type="hidden" value="<?=$row["isbn"]?>" name="isbn">
<input  type="submit" name="delete" value="ลบนาฬิกา"></td>
</td>
</tr>
</form>
</table>
<?
require_once("include/footer.php");
?>

editwatch.php

Code: Select all

<?
session_start();
require_once "../config.php";
require_once "authen.php";
require_once CLASS_BASE."../class/main.class.php";
require_once("headeradmin.php");
?>
<?
require_once("include/connect_db.php");
require_once("include/function.php");

    if(empty($isbn)||empty($price)||empty($author)||empty($title)||empty($publisher)||empty($page)||empty($catid)) {
        echo "<center>กรุณาป้อนรายละเอียดให้ครบถ้วน</center>";
        require_once("include/footer.php");
        exit;
    }
    
//****** function edit 20072009 ******//
    /*$dates = date("dmy_His");    
    if ($tempfile_name == ""){    
        $file="";
    }else{
        $directory = 'MyResize/';  
        if (!copy($tempfile,$directory.$tempfile_name)){ 
            print("Failed to copy $tempfile ....");
        }
        $file=$directory.$tempfile_name; 
        $pos = strrpos($tempfile_name, ".");  
        $stl = strlen($tempfile_name);  
        $ln = $stl - $pos; 
        rename($file,$directory.'file_'.$dates.substr($tempfile_name,$pos,$ln));    
        $directory = 'MyResize/';
        $file=$directory.'file_'.$dates.substr($tempfile_name,$pos,$ln); 
    }*/
            $randnum=rand();
        $dates = date("dmy_His");    
        for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
    {
        if(trim($_FILES["fileUpload"]["tmp_name"][$i]) != NULL)
        {
            copy($_FILES["fileUpload"]["tmp_name"][$i],"MyResize/".'file_'.$dates.$randnum.$_FILES["fileUpload"]["name"][$i]);
            $fileName[$i]='file_'.$dates.$randnum.$_FILES["fileUpload"]["name"][$i];
        }
        
    }
    for($i=0;$fileName[$i]!=null;$i++){
    }    
    //----------------------------จบส่วนของการ upload file------------------------------//    
        //****** end function ******//
    if (edit_book($isbn,$title,$author,$catid,$page,$case_color,$buckle_color,$publisher,$price,$strap,$printing,$case_buckle,$back,$dimension,$weight,$package,$balance,$fileName[0],$fileName[1])){
?>
<script>
    alert("Edit Successfully");
</script>
<meta http-equiv="refresh" content="0;URL=modify_form.php">
<?
        echo "<center>แก้ไขนาฬิกาชื่อ  '$title' ในฐานข้อมูลเสร็จเรียบร้อยแล้ว</center>";
    }else{
        echo "<center>นาฬิกาชื่อ '$title' ไม่สามารถแก้ไขในฐานข้อมูลได้</center>";
    }
require_once("include/footer.php");
?>
คือไม่รู้ว่าจะต้องเช็คยังไง ช่วยบอกด้วยนะคะ ขอคุณค่ะ
mostgirls

Re: อัพเดทข้อมูลแล้วรูปไม่ได้อัพเดท ข้อมูลอยู่ในรูปหายไป

Post by mostgirls »

พอจะอัพเดทข้อมูนนะคะ ถ้าอัพเดทแค่ข้อความ รูปก็จะหาย หรือถ้าอัพเดทรูปแค่รูปเดียว รูปอีกรูปก็จะหายไปด้วย ประมาณนี้ล่ะค่ะ ไม่รู้ว่าจะเข้าใจคำถามรึป่าว แต่ก็ช่วยดูให้ด้วยนะคะ ขอบคุณล่วงหน้าค่ะ
Post Reply

Return to “Programming - PHP”

Who is online

Users browsing this forum: No registered users and 7 guests