|
|
|
แก้ไขภาพค่ะเวลาไม่เลือกรูปภาพแล้วกดแก้ไข ภาพที่มีอยู่แล้วจะหายไปต้องทำแบบไหนคะ ภาพถึงจะยังอยู่ |
|
|
|
|
|
|
|
Code (PHP)
<?php
require_once'connect.php';
if(isset($_POST['save']));{
if(!empty($_FILES['photo']['name'])){
$filename = md5($_FILES['photo']['name'].time());
$ext = explode('.',$_FILES['photo']['name']);
$dest = __DIR__.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$filename.'.'.$ext[1];
if(!copy($_FILES['photo']['tmp_name'], $dest)) {
echo 'upload Error';
exit();
}
$photo = $filename.'.'.$ext[1];
}
$id_employee=$_POST['id_employee'];
$name=$_POST['name'];
$divistion=$_POST['divistion'];
$departmant=$_POST['departmant'];
$duty=$_POST['duty'];
$tel=$_POST['tel'];
$mail=$_POST['mail'];
if(isset($_POST['id_employee'])) {
$sql = "UPDATE employee SET "
. " id_employee = '$id_employee', "
. " name ='$name', "
. " divistion = '$divistion',"
. " departmant = '$departmant',"
. "duty = '$duty',"
. " tel = '$tel', "
. " mail = '$mail', "
. " photo = '$photo' "
. " WHERE id_employee = ". $_POST['id_employee'];
}else{
$sql = "INSERT INTO employee (id_employee,name,divistion,departmant,duty,tel,mail,photo) "
. "VALUES('$id_employee',$name,$divistion,$departmant,$duty,$tel,$mail,'$photo')";
}
mysql_query($sql) or die ('save error');
header('location:list.php');
}
Tag : PHP
|
|
|
|
|
|
Date :
2016-08-30 20:07:57 |
By :
ploynunyamon |
View :
804 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34.
.($photo>''? " , photo = '$photo' " : '')
ต้องเอา , มาไว้หน้า field ง่ายต่อการต่อ string ถ้าเป็นแบบเจ้าของกระทู
ก็หาวิธี ตรวจสอบและ ใส่เอาเองนะครับ
ตัวอย่างการต่อ string
Code (PHP)
$sql = 'update table '
. 'set field1 = aaaa '
. ', field2=bbbb '
. ', field3=ccccc '
. ' where ....';
|
|
|
|
|
Date :
2016-08-30 22:19:44 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|