 |
|
จะทำการ update ค่ะ แต่พอกด edit แล้วกลับไป insert เพิ่มเฉยเลย
ตอนกด edit มันก็ส่งค่าคืนมาที่ฟอร์มนะคะ
อันนี้โค้ดค่ะ
Code
$id=$_GET["id"];
<?
if($action=="save"){
// insert and update to DB
$place_name = $_POST["place_name"];
$place_des = $_POST["descript"];
$driving = $_POST["driving"];
$swim = $_POST["swim"];
$fishing = $_POST["fishing"];
$nature = $_POST["nature"];
$walking = $_POST["walking"];
$shopping = $_POST["shopping"];
$peaceful = $_POST["peaceful"];
$history = $_POST["history"];
$atv = $driving.','.$swim.','.$fishing.','.$nature.','.$walking.','.$shopping.','.$peaceful.','.$history;
$place_type = $_POST["place_type"];
$latitude = $_POST["latitude"];
$longitude = $_POST["longitude"];
$baby = $_POST["baby"];
$old = $_POST["old"];
$disa = $_POST["disa"];
$peo = $baby.','.$old.','.$disa;
move_uploaded_file($_FILES["filUpload"]["tmp_name"],"admin_img/".$_FILES["filUpload"]["name"]); //บcoppy รูปไปไว้ในโฟลเดอร์
$ImageName = $_FILES["filUpload"]["name"];
if($id!=""){
$sql="update place set place_name='$place_name', place_des='$place_des',place_special_ac='$atv',place_special_peo='$peo' ,type_id='$place_type',latitude='$latitude',longitude='$longitude' ,place_img='$ImageName' where place_id='$id'; ";
}else{
$sql="insert into place(place_name,place_des,place_special_ac,place_special_peo,type_id,latitude,longitude,place_img) values('$place_name','$place_des','$atv','$peo','$place_type','$latitude','$longitude','$ImageName');";
}
$result=mysql_query($sql);
header("Location:editplace2.php");
}elseif($action=="del"){ //delete record
$sql="delete from place where place_id='$id';";
$result=mysql_query($sql);
header("Location:editplace2.php");
}elseif($action=="add"){ // Form add and edit
if($id!=""){
$sql="select * from place where place_id='$id';";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
}
?>
ยังไงรบกวนพี่ๆช่วยแนำนำหน่อยนะคะ
ขอบคุณค่ะ
Tag : PHP, MySQL, HTML/CSS
|
|
 |
 |
 |
 |
Date :
2014-02-20 16:26:12 |
By :
iceziism |
View :
792 |
Reply :
15 |
|
 |
 |
 |
 |
|
|
|
 |