Viewing file: condition.php (2.09 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include("../include/class.mysqldb.php");
include("../include/config.inc.php");
if($_REQUEST["action"] == "insertCd"){
$sql = "SELECT * FROM rg_Condition ORDER BY cdId DESC LIMIT 1";
$link->query($sql);
$rs = $link->getnext();
$sql = "INSERT INTO rg_Condition VALUES ('', '" . ($rs->cdCode + 1) . "','" . $_REQUEST["cdName"] . "','" . $_REQUEST["cdNameE"] . "','" . $_REQUEST["cdAbbr"] . "','" . $_REQUEST["cdAbbrE"] . "','" . $_REQUEST["cdType"] . "','" . $_REQUEST["cdMinGrade"] . "','1')";
$link->query($sql);
echo "Insert Success!!";
}
if($_REQUEST["action"] == "deleteCd"){
$sql = "DELETE FROM rg_Condition WHERE cdId = '" . $_REQUEST["cdId"] . "'";
$link->query($sql);
echo "Data deleted.";
}
if($_REQUEST["action"] == "getCdById"){
$sql = "SELECT * FROM rg_Condition WHERE cdId = '".$_REQUEST["cdId"]."'";
$link->query($sql);
echo json_encode($link->getnext());
}
if($_REQUEST["action"] == "getCdAll"){
$sql = "SELECT * FROM rg_Condition";
$link->query($sql);
$i = 1;
while($data = $link->getnext()){
$opt = "<button class='btn btn-primary btn-sm' data-toggle='modal' data-target='#editCondition' data-id='" . $data->cdId . "'>Edit</button>";
$opt .= " <button class='btn btn-danger btn-sm' data-toggle='modal' data-target='#modalDel' data-id='" . $data->cdId . "'>Del</button>";
$json["data"][] = array("No"=>$i++,"cdName"=>"(".$data->cdId.") ".$data->cdName,"cdNameE"=>$data->cdNameE,"cdAbbr"=>$data->cdAbbr,"cdAbbrE"=>$data->cdAbbrE,"cdType"=>$data->cdType,"cdMinGrade"=>$data->cdMinGrade, "opt"=>$opt);
}
echo json_encode($json);
}
if($_REQUEST["action"] == "updateCd"){
$sql = "UPDATE rg_Condition SET cdName='" . $_REQUEST["cdName"] . "', cdNameE='" . $_REQUEST["cdNameE"] . "', cdAbbr='" . $_REQUEST["cdAbbrE"] . "', cdType='" . $_REQUEST["cdType"] . "', cdMinGrade='" . $_REQUEST["cdMinGrade"] . "' WHERE cdId = '".$_REQUEST["cdId"]."'";
$link->query($sql);
echo "Update Success!!";
}
?>
|