getrow($sql); } if ($id == "") { //insert $sql = "INSERT INTO `".$page_tbname."` ( `id` ) VALUES ( NULL );"; $db->query($sql); $id = $db->insert_id(); if($temp_id!=""){ $sql = "UPDATE `attachment` SET `table_id` = '".$id."' WHERE `table_name` = '".$page_tbname."' AND `temp_id` = '".$temp_id."'"; $db->query($sql); } } //update $sql=" UPDATE ".$page_tbname." SET `sorting` = '".escapeit($sorting)."' , `display` = '".escapeit($display)."' , `date` = '".escapeit($date)."' , `name` = '".escapeit($name)."' , `title` = '".escapeit($title)."' , `firstname` = '".escapeit($firstname)."' , `lastname` = '".escapeit($lastname)."' , `mobile` = '".escapeit($mobile)."' , `phone` = '".escapeit($phone)."' , `phone_office` = '".escapeit($phone_office)."' , `phone_type` = '".escapeit($phone_type)."' , `email` = '".escapeit($email)."' , `address` = '".escapeit($address)."' , `district` = '".escapeit($district)."' , `area` = '".escapeit($area)."' where `id` = '$id' "; $db->query($sql); //=========== //upload file if(!empty($_FILES)){ foreach ($_FILES as $key => $value) { $col_name=$key; if($value["name"]!=""){ $file_array = add_attachment($_FILES[$key], "../../".$page_attachment_path, $page_attachment_path, $page_tbname, $id, '', $col_name, $sorting=0); // ============================= // size if($col_name=="photo1" || $col_name=="photo2" || $col_name=="photo3" || $col_name=="photo4" || $col_name=="photo5" || $col_name=="photo6" || $col_name=="photo7" || $col_name=="photo8" || $col_name=="photo9" || $col_name=="photo10" || $col_name=="photo11" || $col_name=="photo12" || $col_name=="photo13" || $col_name=="photo14" || $col_name=="photo15" ){ $width="180"; $height="180"; $filename =$file_array["filename"]; $source_folder= "../../".$page_attachment_path; $destination=$source_folder; $prefix="s"; gen_resize_photo($filename , $source_folder,$destination, $width, $height, $prefix); /* $width="490"; $height="368"; $filename =$file_array["filename"]; $source_folder= "../../".$page_attachment_path; $destination=$source_folder; $prefix="m"; gen_resize_photo($filename , $source_folder,$destination, $width, $height, $prefix); */ } // ============================= } } } //delete file if(!empty($delfiles)){ foreach ($delfiles as $key => $value) { $sql = "SELECT `file_name` FROM `attachment` WHERE `file_name` = '".$value."'"; $rs = mysql_query($sql); $rowfile = mysql_fetch_array($rs); $thedelfile = $rowfile["file_name"]; $sql = "DELETE FROM `attachment` WHERE `file_name` = '".$value."'"; mysql_query($sql); @unlink("../../".$page_attachment_path.$thedelfile); @unlink("../../s_".$page_attachment_path.$thedelfile); @unlink("../../m_".$page_attachment_path.$thedelfile); } } //=========== header("Location: ".$page_address_list."?keepSession=1&page=$page"); exit; ?>