|
|
|
ดู Code ให้หน่อยคับผมเจอปัญหาในการลบข้อมูล ต้องการ Code ลบข้อมูลต้องทำไงคับ ข้อ Code แก้หน่อย |
|
|
|
|
|
|
|
Code นี้เป็นการเพิ่มข้อมูลโดยมี ข้อมูล ข้อมูลรูปภาพ โฟล์เก็บภาพ ต้องนี้ผมต้องการCodeลบข้อมูลต้องทำไงคับ ข้อCodeแก้หน่อย
Code (PHP)
<link href="style.css" rel="stylesheet" type="text/css" />
<?
include("./include/config.php");
include("./include/function.inc.php");
//ตรวจสอบนามสกุล
function randomToken($len) {
srand( date("s") );
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$chars.= "1234567890";
$ret_str = "";
$num = strlen($chars);
for($i=0; $i < $len; $i++) {
$ret_str.= $chars[rand()%$num];
}
return $ret_str;
}
$code = randomToken(30);
//
$Personnel_Pictures= $_POST[Personnel_Pictures];
if(!isset($_POST[Personnel_Pictures])){
$Personnel_Pictures_name=$_FILES["Personnel_Pictures"]["name"];
if(strchr($Personnel_Pictures_name,".")==".JPG" || strchr($Personnel_Pictures_name,".")==".jpg"){
$images = $_FILES["Personnel_Pictures"]["tmp_name"];
$new_images = "$code".$_FILES["Personnel_Pictures"]["name"];
copy($_FILES["Personnel_Pictures"]["tmp_name"],"./photo_personnel/$code".$_FILES["Personnel_Pictures"]["name"]);
$width=200;
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
$sql="DELETE FROM tb_personnel WHERE Personnel_id=$Personnel_id";
$result=mysql_query($sql);
//จัดเก็บลงฐานข้อมูล
$result=mysql_query("INSERT INTO tb_personnel (Personnel_name, Personnel_position, Personnel_Education, Personnel_responsible, Personnel_province, Personnel_herpes, Personnel_retire, Personnel_MAIL, Pe_code, Personnel_Pictures) VALUES ('".$_POST[Personnel_name]."', '".$_POST[Personnel_position]."', '".$_POST[Personnel_Education]."', '".$_POST[Personnel_responsible]."', '".$_POST[Personnel_province]."', '".$_POST[Personnel_herpes]."', '".$_POST[Personnel_retire]."', '".$_POST[Personnel_MAIL]."', '".$_POST[Pe_code]."','$new_images')");
//('$Personnel_name', '$Personnel_position', '$Personnel_Education', '$Personnel_responsible', '$Personnel_province', '$Personnel_herpes', '$Personnel_retire', '$Personnel_MAIL', '$Pe_code')";
echo"<br><center><img src='images/loading.gif'></center>";
echo"<br><center><span class='ms_14_red_bold'>ทำการเพิ่มข้อมูลบุคลากรเรียบร้อยแล้ว</span></center>";
echo"<center><span class='ms_14_nor'>กรุณารอสักครู่ Loading....</span></center>";
?>
<meta http-equiv="refresh" content="2;URL= admin/Personnel_manage.php">
<?
} else {
echo"<br><center><span class='ms_14_red_bold'>ไม่สามารถแก้ไขข้อมูลได้</span></center>";
exit();
}
}
?>
Tag : PHP, MySQL, CakePHP
|
|
|
|
|
|
Date :
2011-10-02 18:23:41 |
By :
seya |
View :
762 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
//*** Delete Record ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM files WHERE FilesID = '".$_GET["FilesID"]."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
@unlink("vdo/".$objResult["FilesName"]);
$strSQL = "DELETE FROM files ";
$strSQL .="WHERE FilesID = '".$_GET["FilesID"]."' ";
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
?>
<a href="allfiles.php">View files</a>
</body>
</html>
Go to : PHP Upload VDO Clip and JW Player (PHP+MySQL)
|
|
|
|
|
Date :
2011-10-02 18:34:17 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|