|
 |
|
update แล้วไม่ขึ้น ช่วยดูให้ทีคับ ดึงข้อมูลมาเพื่อจะแก้ไข อ่ะคับ แต่พออัพไฟล์รูปขึ้นไป แล้วมันติดขึ้นว่า กรุณาใส่ File รูปด้วยครับ |
|
 |
|
|
 |
 |
|
ดึงข้อมูลมาเพื่อจะแก้ไข อ่ะคับ แต่พออัพไฟล์รูปขึ้นไป แล้วมันติดขึ้นว่า
กรุณาใส่ File รูปด้วยครับ
ช่วยดูโค๊ดให้ทีครับผิดตรงไหน
โค๊ตหน้า From
Code (PHP)
<?
$re=mysql_query("select * from p_product where id='$id'");
$num=mysql_num_rows($re);
if($num!=0){
?>
<form id="formregis" name="formregis" method="post" action="update.php" >
<table width="386" border="1" bordercolor="#006600">
<tr>
<td colspan="2" bgcolor="#66CC00"><div align="center"><strong>แก้ไขข้อมูล</strong></div></td>
</tr>
<tr>
<td width="98" height="3"><div align="right">ชื่อ :</div></td>
<td width="272"><div align="left">
<input name="name" type="text" id="name" size="30" maxlength="50" value="<?=mysql_result($re,0,"s_name");?>" />
</div></td>
</tr>
<tr>
<td width="98" height="4"><div align="right">รูป : </div></td>
<td><div align="left"><img src ="../image/<?=mysql_result($re,0,"id")?>" width="50" height="50" /><span class="style27">
<input type="file" name="filepicture" />
</span></div></td>
</tr>
<tr>
<td><div align="right">ชนิด : </div></td>
<td><div align="left">
<select name="status" id="status"value="<?=mysql_result($re,0,"s_status");?>">
<option value="ไม้ดอกชนิดเป็นพุ่ม">ไม้ดอกชนิดเป็นพุ่ม</option>
<option value="ไม้ดอกชนิดเป็นเถา">ไม้ดอกชนิดเป็นเถา</option>
<option value="ไม้ยืนต้นที่ให้ดอก">ไม้ยืนต้นที่ให้ดอก</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="right">ลักษณะ : </div></td>
<td><div align="left">
<textarea name="detail" cols="30" rows="4" id="detail"><?=mysql_result($re,0,"s_detail");?>
</textarea>
</div></td>
</tr>
<tr>
<td><div align="right">การขยายพันธู์ : </div></td>
<td><div align="left">
<input name="detail2" type="text" id="detail2" size="30" maxlength="50" value="<?=mysql_result($re,0,"s_detail2");?>" />
</div></td>
</tr>
<tr>
<td><div align="right">ราคา : </div></td>
<td><div align="left">
<input name="price" type="text" id="price" size="30" maxlength="50" value="<?=mysql_result($re,0,"s_price");?>" />
</div></td>
</tr>
<tr>
<td> </td>
<td><table width="272" border="0">
<tr>
<td width="136"><div align="center">
<input type="submit" name="Submit" value="ส่งข้อมูล" />
</div></td>
<td width="126"><div align="center"></div></td>
</tr>
</table></td>
</tr>
</table>
<input type="hidden" name="id" value="<?=$id?>">
</form>
<? }?>
หน้าโค๊ตครับ
Code (PHP)
$pic = $_FILES["filepicture"] ;
$pic_name = $pic["name"] ;
$pic_type = $pic["type"] ;
$pic_size = $pic["size"] ;
$pic_temp = $pic["tmp_name"] ;
// Check รูปภาพ
if ($pic_size == null) { // No Upload
echo "กรุณาใส่ Flie รูปภาพด้วยครับ<br />" ;
echo "<a href = 'javascript:history.back();'>Back</a>" ;
return ;
}// Check size ขนาด 100 k
else if ($pic_size > 500*1024)
{
echo "Flie รูปภาพของคุณมีขนาดใหญ่เกินไป<br />" ;
echo "<a href = 'javascript:history.back();'>Back</a>" ;
return ;
}// Check type หรือ check ชนิด
else if ($pic_type != "image/gif" && $pic_type != "image/pjpeg")
{
echo "กรุณาตรวจสอบ Flie รูปภาพด้วยครับ<br />" ;
echo "<a href = 'javascript:history.back();'>Back</a>" ;
return ;
}
$sql = "update p_product set s_name='$name' ,s_status='$status' , s_detail='$detail', s_detail2='$detail2', s_price='$price' where id='$id'";
$sqlquery=mysql_db_query($dbname, $sql);
// Save Picture
if($pic_size > 0) {
$pic_new = "../image/$id.jpg" ;
unlink("../image/$id.jpg") ; // คือการลบรูปที่ เลขตาม id อะไร
move_uploaded_file($pic_temp,$pic_new) ; // เป็นฟังก์ชั่น การ ย้ายไฟล์จากโฟว์เดอร์ 1 ไปโฟว์เดอร์ 1
}
***ช่วยดูให้ที่นะครับ มือใหม่หัดเขียน ส่งจารณ์ อิอิ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-11-03 22:21:25 |
By :
artcomclub |
View :
909 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ ขอบคุณมากเลยนะครับ
|
 |
 |
 |
 |
Date :
2009-11-03 22:37:18 |
By :
artcomclub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|