| Server IP : 134.236.49.22 / Your IP : 216.73.216.114 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/room/room/equip/ |
Upload File : |
<?php
session_start();
if ($_SESSION['status']!='admin') {
echo "<script>alert('session ผิดผลาด'); window.location ='../index.php';</script>";
exit();
} else {
include '../connect.php';
}
//เพิ่มข้อมูล
if ($_GET['action']=='add'){
$meSQL = "INSERT INTO tb_equipment (name_equipment) VALUES ('".$_POST["Name"]."')";
$meQuery = $conn->query($meSQL);
if ($meQuery == TRUE) {
echo "<script>alert('เพิ่มข้อมูลเสร็จเรียบร้อยแล้ว'); window.location ='../index.php?page=equip';</script>";
} else {
echo "<script>alert('มีปัญหาการบันทึกข้อมูล กรุณากลับไปบันทึกใหม่');history.back(-1);</script>";
exit();
}
}
//แก้ไขข้อมูล
if ($_GET['action']=='edit'){
$meSQL = "UPDATE tb_equipment ";
$meSQL .="SET name_equipment='{$_POST['Name']}' ";
$meSQL .= "WHERE id_equipment='{$_POST['id']}' ";
$meQuery = $conn->query($meSQL);
if ($meQuery == TRUE) {
echo "<script>alert('บันทึกข้อมูลเรียบร้อยแล้ว');window.location ='../index.php?page=equip'; </script>";
} else {
echo "<script>alert('มีปัญหาการบันทึกข้อมูล กรุณากลับไปบันทึกใหม่');history.back(-1);</script>";
exit();
}
}
//ลบข้อมูล
if ($_GET['action']=='delete'){
$meSQL = "DELETE FROM tb_equipment ";
$meSQL .= "WHERE id_equipment='{$_GET['id']}' ";
$meQuery = $conn->query($meSQL);
if ($meQuery == TRUE) {
echo "<script>alert('ลบข้อมูลสำเร็จ'); window.location ='../index.php?page=equip';</script>";
} else {
echo "<script>alert('มีปัญหาการลบข้อมูล '); history.back(-1);</script>";
exit();
}
}
if(isset($_REQUEST['action']) and $_REQUEST['action']=="updateSortedRows"){
$newOrder = explode(",",$_REQUEST['sortOrder']);
$n = '1';
foreach($newOrder as $id){
$conn->query('UPDATE tb_equipment SET position="'.$n.'" WHERE id_equipment="'.$id.'" ');
$n++;
}
}
$conn->close();
?>