require_once BASE_PATH . '/login_handler.php';
/*
	Login handling and permission check
*/
$login = new loginHandler($config);
if (!$login->is_logged_in()) {
    $login->redirect_login('Please login');
}
if ($login->get_user_type() != 'admin') {
    $login->not_authorized_error();
}
if (!isset($_GET['courseid'])) {
    header("Location: " . $config['url']['base_url'] . $config['url']['error'] . '?msg=' . base64_encode('Invalid Course id.'));
}
require_once "ajax_table.class.php";
$obj = new ajax_table(['courseid' => $_GET['courseid']]);
$records = $obj->getRecords();
//echo phpinfo();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title>Ajax Table Inline Edit</title>
  <script>
	 // Column names must be identical to the actual column names in the database, if you dont want to reveal the column names, you can map them with the different names at the server side.
	 var columns = new Array("question","type");
	 var placeholder = new Array("Enter Question","Select Type");
	 var inputType = new Array("text","select");
	 var table = "tableDemo";
	 var selectOpt = new Array("radio","comment");;
<?php

require_once "ajax_table.class.php";
$obj = new ajax_table();
$conn = $obj->dbconnect();
function array_map_callback($a)
{
    global $conn;
    return mysqli_real_escape_string($conn, $a);
}
if (isset($_POST) && count($_POST)) {
    // whats the action ??
    $action = $_POST['action'];
    unset($_POST['action']);
    if ($action == "save") {
        // remove 'action' key from array, we no longer need it
        // Never ever believe on end user, he could be a evil minded
        $escapedPost = array_map('array_map_callback', $_POST);
        $escapedPost = array_map('htmlentities', $escapedPost);
        $res = $obj->save($escapedPost);
        if ($res) {
            $escapedPost["success"] = "1";
            $escapedPost["id"] = $res;
            echo json_encode($escapedPost);
        } else {
            echo $obj->error("save");
        }
    } else {
        if ($action == "del") {
            $id = $_POST['rid'];
            $res = $obj->delete_record($id);
<?php 
include "ajax_table.class.php";
$obj = new ajax_table();
$records = $obj->getRecords();
$conn = $obj->dbconnect();
//echo phpinfo();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <style type="text/css">

 body{
            font-size:1.2em;

        }
        th,td{
            text-align:center;
        }
    </style>
    <title>Change the Informations</title>
    <script>
        // Column names must be identical to the actual column names in the database, if you dont want to reveal the column names, you can map them with the different names at the server side.
        var columns = new Array("division","district","thana","sub_office","post_code","outside_of_dhaka");
        var placeholder = new Array("Enter Division","Enter District","Enter Thana","Enter Sub_Office","Enter Post_Code","Enter Outside_Of_Dhaka");