Skip to main content

Datatables Add Edit Delete with Ajax, PHP & MySQL

HTML Tables are extensively used in web applications to display data in rows and columns. The tables are just HTML element and can only be used to display records. But if you’re want HTML Table which are interactive and have features like sorting, search, pagination then you’re here at right place.

In this tutorial you will learn about jQuery Datatables plugin to create interactive and feature rich HTML tables with dynamic data. We will create Live Datatables to add, update and delete records with PHP and MySQL. We will handle to refresh Datatables when any record updated or delete from table.

We will cover this tutorial step by step by create live example of Datatables with add, edit and delete records using PHP and MySQL.

Also, read:

So let’s start implementing Live Datatables to add, edit and delete records with PHP and MySQL. Before we begin, take a look on files structure for this example.

  • index.php
  • data.js
  • action.php
  • Employee.php: A class to hold employee method.

Step1: Create MySQL Database Table

As we will add, edit and delete records, so first we will create MySQL database table employee to perform employee operations.

CREATE TABLE `employee` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `skills` varchar(255) NOT NULL,
  `address` varchar(255) NOT NULL,
  `designation` varchar(255) NOT NULL,
  `age` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Step2: Include Bootstrap, jQuery and Datatables files

In index.php file, we will include Bootstrap, jQuery and jQuery Datatables plugin files.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<script src="js/dataTables.bootstrap.min.js"></script>		
<link rel="stylesheet" href="css/dataTables.bootstrap.min.css" />
<script src="js/data.js"></script>

Step3: Create HTML Table

In index.php file, we will create HTML table to list employee records. The HTML Table will be converted to Datatables with employee records listings.

<table id="employeeList" class="table table-bordered table-striped">
	<thead>
		<tr>
			<th>ID</th>
			<th>Name</th>
			<th>Age</th>					
			<th>Skills</th>
			<th>Address</th>
			<th>Designation</th>					
			<th></th>
			<th></th>					
		</tr>
	</thead>
</table>

Step3: Load Datatables with Employee Records

In data.js JavaScript file, we will initialize Datatables and load employee records by making Ajax request to action listEmployee to call Employee class method employeeList() to return employee JSON data.

var employeeData = $('#employeeList').DataTable({
	"lengthChange": false,
	"processing":true,
	"serverSide":true,
	"order":[],
	"ajax":{
		url:"action.php",
		type:"POST",
		data:{action:'listEmployee'},
		dataType:"json"
	},
	"columnDefs":[
		{
			"targets":[0, 6, 7],
			"orderable":false,
		},
	],
	"pageLength": 10
});		

Step4: Get Employee List from MySQL Database Tables

In class Employee.php, we will create method employeeList() to get employee list according to Datatables data request to return employee list as JSON data.

public function employeeList(){		
	$sqlQuery = "SELECT * FROM ".$this->empTable." ";
	if(!empty($_POST["search"]["value"])){
		$sqlQuery .= 'where(id LIKE "%'.$_POST["search"]["value"].'%" ';
		$sqlQuery .= ' OR name LIKE "%'.$_POST["search"]["value"].'%" ';			
		$sqlQuery .= ' OR designation LIKE "%'.$_POST["search"]["value"].'%" ';
		$sqlQuery .= ' OR address LIKE "%'.$_POST["search"]["value"].'%" ';
		$sqlQuery .= ' OR skills LIKE "%'.$_POST["search"]["value"].'%") ';			
	}
	if(!empty($_POST["order"])){
		$sqlQuery .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' ';
	} else {
		$sqlQuery .= 'ORDER BY id DESC ';
	}
	if($_POST["length"] != -1){
		$sqlQuery .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
	}	
	$result = mysqli_query($this->dbConnect, $sqlQuery);

        // Updated for pagination	
        $sqlQuery1 = "SELECT * FROM ".$this->empTable." ";
	$result1 = mysqli_query($this->dbConnect, $sqlQuery1);
	$numRows = mysqli_num_rows($result1);       
        
	$employeeData = array();	
	while( $employee = mysqli_fetch_assoc($result) ) {		
		$empRows = array();			
		$empRows[] = $employee['id'];
		$empRows[] = ucfirst($employee['name']);
		$empRows[] = $employee['age'];		
		$empRows[] = $employee['skills'];	
		$empRows[] = $employee['address'];
		$empRows[] = $employee['designation'];					
		$empRows[] = '<button type="button" name="update" id="'.$employee["id"].'" class="btn btn-warning btn-xs update">Update</button>';
		$empRows[] = '<button type="button" name="delete" id="'.$employee["id"].'" class="btn btn-danger btn-xs delete" >Delete</button>';
		$employeeData[] = $empRows;
	}
	$output = array(
		"draw"				=>	intval($_POST["draw"]),
		"recordsTotal"  	=>  $numRows,
		"recordsFiltered" 	=> 	$numRows,
		"data"    			=> 	$employeeData
	);
	echo json_encode($output);
}

Step5: Create HTML Form Modal to Add Update Datatables Records

In index.php file, we will create Bootstrap HTML model to add and update new records.

<div id="employeeModal" class="modal fade">
	<div class="modal-dialog">
		<form method="post" id="employeeForm">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">×</button>
					<h4 class="modal-title"><i class="fa fa-plus"></i> Edit User</h4>
				</div>
				<div class="modal-body">
					<div class="form-group"
						<label for="name" class="control-label">Name</label>
						<input type="text" class="form-control" id="empName" name="empName" placeholder="Name" required>			
					</div>
					<div class="form-group">
						<label for="age" class="control-label">Age</label>							
						<input type="number" class="form-control" id="empAge" name="empAge" placeholder="Age">							
					</div>	   	
					<div class="form-group">
						<label for="lastname" class="control-label">Skills</label>							
						<input type="text" class="form-control"  id="empSkills" name="empSkills" placeholder="Skills" required>							
					</div>	 
					<div class="form-group">
						<label for="address" class="control-label">Address</label>							
						<textarea class="form-control" rows="5" id="address" name="address"></textarea>							
					</div>
					<div class="form-group">
						<label for="lastname" class="control-label">Designation</label>							
						<input type="text" class="form-control" id="designation" name="designation" placeholder="Designation">			
					</div>						
				</div>
				<div class="modal-footer">
					<input type="hidden" name="empId" id="empId" />
					<input type="hidden" name="action" id="action" value="" />
					<input type="submit" name="save" id="save" class="btn btn-info" value="Save" />
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				</div>
			</div>
		</form>
	</div>
</div>

Step6: Handle Add New Employee Record

In data.js, we will handle Bootstrap modal form submit to submit form and make Ajax request to post data to action addEmployee to call employee class method addEmployee() to insert new employee records to database.

$("#employeeModal").on('submit','#employeeForm', function(event){
	event.preventDefault();
	$('#save').attr('disabled','disabled');
	var formData = $(this).serialize();
	$.ajax({
		url:"action.php",
		method:"POST",
		data:formData,
		success:function(data){				
			$('#employeeForm')[0].reset();
			$('#employeeModal').modal('hide');				
			$('#save').attr('disabled', false);
			employeeData.ajax.reload();
		}
	})
});		

Step7: Save New Employee Record to Database Table

In class Employee.php, we will create method to insert employee record to table employee.

public function addEmployee(){
	$insertQuery = "INSERT INTO ".$this->empTable." (name, age, skills, address, designation) 
		VALUES ('".$_POST["empName"]."', '".$_POST["empAge"]."', '".$_POST["empSkills"]."', '".$_POST["address"]."', '".$_POST["designation"]."')";
	$isUpdated = mysqli_query($this->dbConnect, $insertQuery);		
}

Step8: Handle Employee Record Update

In data.js file, we will make Ajax request to action getEmployee to get employee from database to display in employee edit form modal to edit employee details.

$("#employeeList").on('click', '.update', function(){
	var empId = $(this).attr("id");
	var action = 'getEmployee';
	$.ajax({
		url:'action.php',
		method:"POST",
		data:{empId:empId, action:action},
		dataType:"json",
		success:function(data){
			$('#employeeModal').modal('show');
			$('#empId').val(data.id);
			$('#empName').val(data.name);
			$('#empAge').val(data.age);
			$('#empSkills').val(data.skills);				
			$('#address').val(data.address);
			$('#designation').val(data.designation);	
			$('.modal-title').html("<i class='fa fa-plus'></i> Edit Employee");
			$('#action').val('updateEmployee');
			$('#save').val('Save');
		}
	})
});

Step9: Edit Save Employee Record

In class Employee.php, we will create method updateEmployee() to update in database table.

public function updateEmployee(){
	if($_POST['empId']) {	
		$updateQuery = "UPDATE ".$this->empTable." 
		SET name = '".$_POST["empName"]."', age = '".$_POST["empAge"]."', skills = '".$_POST["empSkills"]."', address = '".$_POST["address"]."' , designation = '".$_POST["designation"]."'
		WHERE id ='".$_POST["empId"]."'";
		$isUpdated = mysqli_query($this->dbConnect, $updateQuery);		
	}	
}

Step10: Handle Delete Employee Record

In data.js file, we wil handle employee record delete by making ajax request to action empDelete and call method deleteEmployee() to delete employee record.

$("#employeeList").on('click', '.delete', function(){
	var empId = $(this).attr("id");		
	var action = "empDelete";
	if(confirm("Are you sure you want to delete this employee?")) {
		$.ajax({
			url:"action.php",
			method:"POST",
			data:{empId:empId, action:action},
			success:function(data) {					
				employeeData.ajax.reload();
			}
		})
	} else {
		return false;
	}
});	

Step11: Delete Employee Record from MySQL Database Table

In class Employee.php, we will create method deleteEmployee() to create employee record from database table.

public function deleteEmployee(){
	if($_POST["empId"]) {
		$sqlDelete = "
			DELETE FROM ".$this->empTable."
			WHERE id = '".$_POST["empId"]."'";		
		mysqli_query($this->dbConnect, $sqlDelete);		
	}
}

You may also like:

You can view the live demo from the Demo link and can download the script from the Download link below.
Demo Download

94 thoughts on “Datatables Add Edit Delete with Ajax, PHP & MySQL

  1. Hi,
    i just want to alert message like “Update ok” after push the Save Button.

    success:function(data){
    $(‘#employeeModal’).modal(‘show’);
    $(‘#empId’).val(data.id);
    $(‘#empName’).val(data.name);
    $(‘#empAge’).val(data.age);
    $(‘#empSkills’).val(data.skills);
    $(‘#address’).val(data.address);
    $(‘#designation’).val(data.designation);
    $(‘.modal-title’).html(“empTable.”
    SET name = ‘”.$_POST[“empName”].”‘, age = ‘”.$_POST[“empAge”].”‘, skills = ‘”.$_POST[“empSkills”].”‘, address = ‘”.$_POST[“address”].”‘ , designation = ‘”.$_POST[“designation”].”‘
    WHERE id ='”.$_POST[“empId”].”‘”;
    $isUpdated = mysqli_query($this->dbConnect, $updateQuery);

    if($isUpdated){
    $response_array[‘status’] = ‘success’;
    }

    echo json_encode($response_array);
    }
    }

    but it doesn’t work.

  2. The Add Employee script doesn’t add record to database. Everything else is working great. Is there a known problem in the code for this?

    1. yes, its disabled in live demo, it’s working in project code. You can download code and can run your server. thanks!

  3. Hi, I don’t understand why the AddEmployee button doesn’t work, I can delete and modify the line but I can’t add it. He gives me no mistakes anywhere. When I press the button it doesn’t even save in the db

    1. it’s disabled in live demo, you can download project code and run on your server. thanks!

  4. fix the pagination button and get all row
    Add code to Employee.php
    $numRows = mysqli_num_rows($result);
    $numTotal = mysqli_num_rows(mysqli_query($this->dbConnect,”SELECT id FROM “.$this->empTable.” “)); // get total row

    Change all $output
    $output = array(
    “draw” => intval($_POST[“draw”]),
    “recordsTotal” => $numTotal,
    “recordsFiltered” => $numRows,
    “iTotalDisplayRecords” => $numTotal,
    “data” => $employeeData
    );
    Done!

  5. Very good work!
    If you could also sort the rows of the table by drag and drop with sql Update, it would be perfect!

  6. Hello,

    To allow the update modal to work, change “MYSQL_ASSOC” to “MYSQLI_ASSOC”.. Refer to line 90 in the Employee.php file.

  7. Hi, I have just been through the fixes that JOSHUA HANSEN posted in the comments and I can now happily say it is working as expected.

    Alan

  8. Hi, really cool Bootstrap CRUD.
    After several tweaks to get it working (the comments here helped overcome the auto increment and MSQLI_ASSOC in order to get edit of existing records working)

    I am however stuck on trying to get the pagination working I have added more than 10 records (13 actually) you can see these if you order by name etc.
    Even though I have more than 10 records it only says it is showing 1 to 10 of 10 entries. And the next button is disabled.

    Can you please assist me in resolving this issue.

    Regards

    Alan

  9. Hi, I can’t add a new record or update an existing one but I can delete records.

    Both modals open but nothing is sent to database when I save.

    I’ve looked at Developer Tools in Chrome but don’t really know what I’m looking for?

  10. Anyone get the syntax right for pagination? Added it to the data.js file and still no option to go to next page. Someone have a code snippet where it works?

    1. You can get the total record count and pass to “recordsTotal” array and it will work pagination correctly. I will also update the script to work it correctly. Thanks!

  11. Thanks a lot, this post was a great help!
    I have only one problem. In case there are mysql errors, how can I manage the sending of an alert popup to the user?

  12. Hello:

    I downloaded your project and I am getting the following error, not displaying any data. My data is O.K.
    The error is
    DataTables warning: table id=employeeList – Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

    Till now, no body complain like this error, hope you can help me out with suggestion. I used another project, same thing happens too.

    Regards
    Shamsul Arifin

    1. May be there are error in getting data from database to return json response. Please check that. Thanks!

  13. Nice work. I like the Demo.

    Where do I copy the project zip file for complete source codes

  14. “Add employee” is not working. You have to set the id in the database as a primary key and auto increment.

  15. hello, and you can do autorefresh? So that you don’t have to refresh the page to see the changes made by other users?

    great guide, thank you

  16. Hello, some problem on sorting, the 1° column sorts the 0°, the 2° sorts the 1° and so on!!!
    Tanks!
    Davide

        1. if(!empty($_POST[“order”])){
          $_POST[‘order’][‘0’][‘column’] = $_POST[‘order’][‘0’][‘column’] + 1; //added for right sorting
          $sqlQuery .= ‘ smazano is NULL ORDER BY ‘.$_POST[‘order’][‘0’][‘column’].’ ‘.$_POST[‘order’][‘0’][‘dir’].’ ‘;

  17. Hello and thanks for this project!
    I’ve 2 problemz:
    1)when i click on Update button, null data in firefox debug network xhr answer/reply tab instead of JSON data but the modal show;
    2) search do not works!

    Add and delete works fine!

    Tanks!

      1. Update solved….you forgot to write the I in MYSQL_ASSOC in Employee.php instead of MSQLI_ASSOC

        public function getEmployee(){
        if($_POST[“empId”]) {
        $sqlQuery = “SELECT * FROM “.$this->empTable.” WHERE id = ‘”.$_POST[“empId”].”‘”;
        $result = mysqli_query($this->dbConnect, $sqlQuery);
        $row = mysqli_fetch_array($result, MYSQL_ASSOC); < NO I
        echo json_encode($row);

      2. Search issue…
        Well the ‘ ( ‘ after ‘ WHERE ‘ should be there, because at the end of ‘ %” ‘ there is a ‘ ) ‘ and that closes the code.
        You should have space between’ WHERE ‘ and ‘ (id ‘ but it’s ‘ WHERE(id ‘ .
        Just like ‘ OR ‘

        That solved the problem

  18. if(!empty($_POST[“search”][“value”])){
    $sqlQuery .= ‘where(id LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (first_name LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (last_name LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (position LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (office LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (extn LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (age LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (salary LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (start_date LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    $sqlQuery .= ‘ OR (email LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    }

    just copy and paste, it missing parentheses or “round brackets” ( )

    1. Hi, I have added one more column and everything is okay, except, when click on update button, data not loaded in that particular new column but others (old) are ok? please suggest to solve it please.

  19. Hey, why is the Search function not working? Its says that there is an Ajax error. I’ve been looking for a solution for a while but I couldn’t find anything :/

  20. Hello,

    thank you for that.

    I added another column. Unfortunately the sorting and searching does not work then.

    The sort symbol is then displayed on the far right above delete.

    I would be very grateful for help!

  21. I found the two issues plaguing your excellent code.

    1. Pagination

    Change the order of the $result / $numRows in the Employee.php file.

    if(!empty($_POST[“order”])){
    $sqlQuery .= ‘ORDER BY ‘.$_POST[‘order’][‘0’][‘column’].’ ‘.$_POST[‘order’][‘0’][‘dir’].’ ‘;
    } else {
    $sqlQuery .= ‘ORDER BY id DESC ‘;
    }

    $result = mysqli_query($this->dbConnect, $sqlQuery);
    $numRows = mysqli_num_rows($result);

    if($_POST[“length”] != -1){
    $sqlQuery .= ‘LIMIT ‘ . $_POST[‘start’] . ‘, ‘ . $_POST[‘length’];
    }
    $result = mysqli_query($this->dbConnect, $sqlQuery);
    // Comment this out $numRows = mysqli_num_rows($result);

    2. Update Button Not Working:

    Update this section in the Employee.php file to update MYSQL_ASSOC to MYSQLI_ASSOC

    public function getEmployee(){
    if($_POST[“empId”]) {
    $sqlQuery = ”
    SELECT * FROM “.$this->empTable.”
    WHERE id = ‘”.$_POST[“empId”].”‘”;
    $result = mysqli_query($this->dbConnect, $sqlQuery);
    $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
    echo json_encode($row);
    }
    }

    These changes fixed the issues I was having, along with the previously mentioned change of the ID to auto_increment.

    Great stuff! Thank you very much!

      1. Pagination doesn´t work. I have made the changes to the code and still next button is disabled.
        Search box doesn´t work either.
        What could be wrong?
        Pls help!
        Thanks!!

    1. Pagination doesn’t work 🙁
      Search box does not work either.
      I don´t know what to do. Can you help?
      I have made the changes in code that JOSHUA HANSEN said and still can not get the pagination work.
      please help!

      1. if(!empty($_POST[“search”][“value”])){
        $sqlQuery .= ‘AND (id LIKE “%’.$_POST[“search”][“value”].’%” ‘;
        $sqlQuery .= ‘ OR first_name LIKE “%’.$_POST[“search”][“value”].’%” ‘;
        $sqlQuery .= ‘ OR last_name LIKE “%’.$_POST[“search”][“value”].’%” ‘;
        $sqlQuery .= ‘ OR designation LIKE “%’.$_POST[“search”][“value”].’%” ‘;
        $sqlQuery .= ‘ OR status LIKE “%’.$_POST[“search”][“value”].’%” ‘;
        $sqlQuery .= ‘ OR mobile LIKE “%’.$_POST[“search”][“value”].’%” )’;
        }
        Place this solution, It will work!
        All the best

    2. As above, also, age is in the wrong place when you create the table, so it messes up the column sorting.

      CREATE TABLE `employee` (
      `id` int(11) NOT NULL,
      `name` varchar(255) NOT NULL,
      `age` int(11) NOT NULL
      `skills` varchar(255) NOT NULL,
      `address` varchar(255) NOT NULL,
      `designation` varchar(255) NOT NULL,
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

      Also, for sorting, you need to add +1 to the columns post

      if(!empty($_POST[“order”])){
      $_POST[‘order’][‘0’][‘column’] = $_POST[‘order’][‘0’][‘column’] + 1;
      $sqlQuery .= ‘ORDER BY ‘.$_POST[‘order’][‘0’][‘column’].’ ‘.$_POST[‘order’][‘0’][‘dir’].’ ‘;
      } else {
      $sqlQuery .= ‘ORDER BY id ASC ‘;
      }

    3. The solution proposed for the pagination is correct, regarding the update button, it is enough to convert the ID field into AUTO_INCREMENT
      Thank you so much for everything

  22. “paging”:true,
    “lengthChange”: false,
    “processing”:true,

    the pagination is till not working.
    and the update button still won’t work and there are no Ajax response error

  23. Hello,
    I just tried your online demo and the pagination doesn’t work either, please could you provide some help?

    1. you can use option “paging:true” in data.js JavaScript file when initialize $(‘#employeeList’).DataTable(). thanks!

  24. Hello,
    Thanks for the tutorial, but i’m having some issues with your code and i was wondering if you could help me out:
    1-The codes in the demo zip files are differents from what’s post here, so which ones should i use?
    2-When data exceeds 10 rows, the “next” button doesn’t work

    1. You can download the zip file and use that. You need to use “paging”: true, option for pagination when initialize datatables. thanks!

  25. Sorting for ID is not there but it functions when we click on name , similary for others .. but there is no sorting option for Age.

    1. Yes sorting for id not handled. You can handled it at your end by passing sort option when initialize datatables. You can also add sorting for age. thanks!

  26. Nice script, but there is something wrong in the pagination code.

    You should make 2 querys to get the total result, and the page result.

    $sqlQuery = “SELECT * FROM “.$this->empTable.” “;
    if(!empty($_POST[“search”][“value”])){
    $sqlQuery .= ‘where(id LIKE “%’.$_POST[“search”][“value”].’%” ‘;
    $sqlQuery .= ‘ OR name LIKE “%’.$_POST[“search”][“value”].’%” ‘;
    $sqlQuery .= ‘ OR designation LIKE “%’.$_POST[“search”][“value”].’%” ‘;
    $sqlQuery .= ‘ OR address LIKE “%’.$_POST[“search”][“value”].’%” ‘;
    $sqlQuery .= ‘ OR skills LIKE “%’.$_POST[“search”][“value”].’%”) ‘;
    }
    if(!empty($_POST[“order”])){
    $sqlQuery .= ‘ORDER BY ‘.$_POST[‘order’][‘0’][‘column’].’ ‘.$_POST[‘order’][‘0’][‘dir’].’ ‘;
    } else {
    $sqlQuery .= ‘ORDER BY id DESC ‘;
    }

    $result = mysqli_query($this->dbConnect, $sqlQuery);
    $numRows = mysqli_num_rows($result);

    if($_POST[“length”] != -1){
    $sqlQuery .= ‘LIMIT ‘ . $_POST[‘start’] . ‘, ‘ . $_POST[‘length’];
    }
    $result = mysqli_query($this->dbConnect, $sqlQuery);

    Best regards,

  27. HI WHAT’S UP I HAVE A ERROR, YOU CAN HELP ME?

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\AppServ\www\SISERSAN\tablas2\Employee.php on line 62

    Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\AppServ\www\SISERSAN\tablas2\Employee.php on line 64
    {“draw”:1,”recordsTotal”:null,”recordsFiltered”:null,”data”:[]}

  28. the update button does not work can help me
    and when the data is inserted in the db they are shown with id 0

    1. Please make employee table’s column id as auto increment to work it correctly. Thanks.

        1. Change action.php

          $row = mysqli_fetch_array($result, MYSQL_ASSOC);
          to

          $row = mysqli_fetch_assoc($result);

Comments are closed.