response.php
String.Format("<a href='/{0}'>view</a> <a href='/{0}'>edit</a>", item.ID),
<?php
include("connection.php");
$db = new dbObj();
$connString = $db->getConnstring();
$params = $_REQUEST;
$action = isset($params['action']) != '' ? $params['action'] : '';
$empCls = new Employee($connString);
switch($action) {
case 'add':
$empCls->insertEmployee($params);
break;
case 'edit':
$empCls->updateEmployee($params);
break;
case 'delete':
$empCls->deleteEmployee($params);
break;
default:
$empCls->getEmployees($params);
return;
}
class Employee {
protected $conn;
protected $data = array();
function __construct($connString) {
$this->conn = $connString;
}
public function getEmployees($params) {
$this->data = $this->getRecords($params);
echo json_encode($this->data);
}
function insertEmployee($params) {
$data = array();;
// $sql = "INSERT INTO `employee` (employee_name, employee_salary, employee_age) VALUES('" . $params["name"] . "', '" . $params["salary"] . "','" . $params["age"] . "'); ";
$sql = "INSERT INTO evidencija (ime, otac, datum, napomena, prilog, status) VALUES('" . $params["ime"] . "', '" . $params["otac"] . "','" . $params["datum"] . "','" . $params["napomena"] . "','" . $params["prilog"] . "','" . $params["status"] . "'); ";
echo $result = mysqli_query($this->conn, $sql) or die("error to insert - data");
}
function getRecords() {
$rp = isset($_POST['rp']) ? $_POST['rp'] : 10;
$sortname = isset($_POST['sortname']) ? $_POST['sortname'] : 'ime';
$sortorder = isset($_POST['sortorder']) ? $_POST['sortorder'] : 'desc';
$query = isset($_POST['query']) ? $_POST['query'] : false;
$qtype = isset($_POST['qtype']) ? $_POST['qtype'] : false;
if (isset($_POST['page'])) { $page = $_POST['page']; } else { $page=1; };
$start_from = ($page-1) * $rp;
$where = "";
if ($query) {$where = " WHERE $qtype LIKE '%$query%' ";
$sort = "ORDER BY $sortname $sortorder";
//$sql = "SELECT iso,name,printable_name,iso3,numcode FROM country $where $sort $limit";
$sql = "SELECT * FROM evidencija ". $where." ". $sort;
$sqlTot = $sql;
}
else
{
$sql = "SELECT * FROM evidencija order by ".$sortname." ".$sortorder." LIMIT ". $start_from .",".$rp;
$sqlTot = "SELECT * FROM evidencija";
}
$qtot = mysqli_query($this->conn, $sqlTot) or die("error to fetch tot * data");
$queryRecords = mysqli_query($this->conn, $sql) or die("error to fetch * data");
while( $row = mysqli_fetch_assoc($queryRecords) ) {
$data[] = $row;
//echo "<pre>";print_R($data);die;
//$data[] = "<a href=./".$row.">".$row."</a>";
}
$json_data = array(
"page" => $page,
"total" => intval($qtot->num_rows),
"rows" => $data // total data array
);
return $json_data;
}
function updateEmployee($params) {
$data = array();
//print_R($_POST);die;
// $sql = "Update `employee` set employee_name = '" . $params["edit_name"] . "', employee_salary='" . $params["edit_salary"]."', employee_age='" . $params["edit_age"] . "' WHERE id='".$_POST["edit_id"]."'";
$sql = "Update evidencija set ime = '" . $params["edit_ime"] . "', otac='" . $params["edit_otac"] . "', datum='" . $params["edit_datum"] . "', napomena='" . $params["edit_napomena"] . "', prilog='" . $params["edit_prilog"] . "', status='" . $params["edit_status"] . "' WHERE id='".$_POST["edit_id"]."'";
echo $result = mysqli_query($this->conn, $sql) or die("error to update - data");
}
function deleteEmployee($params) {
$data = array();
//print_R($_POST);die;
$sql = "delete from evidencija WHERE id='".$params["id"]."'";
echo $result = mysqli_query($this->conn, $sql) or die("error to delete - data");
}
}
?>
https://www.experts-exchange.com/questions/28498124/link-to-hyperlink-contained-in-table-row-in-a-javascript-function.html
https://onedrive.live.com/?authkey=%21AIrZFxqfvpSKaHo&cid=F8FFD0AC30BCE424&id=F8FFD0AC30BCE424%21114&parId=root&action=locate