Getting Data from row which button is clicked - javascript

I have the following ajax that needs to pass the userID to a PHP script.
document.getElementById("delete").addEventListener("click", function(){
if (confirm("Are you sure you want to delete this user's account?")) {
$.ajax({
url: 'deleteUser.php?id='+<?php echo $userID ?>,
success: function(data) {
toastr.danger("User successfully deleted!");
}
});
} else {
}
});
I'm unsure how to actually get the row data from the button used since they're posted in the TD of each row as it goes through each record in the set. How would one accomplish this?
<table class="table table-bordered">
<thead class="thead-dark">
<tr>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Email</th>
<th scope="col">Username</th>
<th scope="col">Account Type</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php
$query = $pdo->query("SELECT * FROM accounts WHERE company ='".$res['company']."' ")->fetchall();
foreach($query as $row){
echo ' <tr>';
echo ' <td>'.$row['fname'].'</td>' ;
echo ' <td>'.$row['lname'].'</td>' ;
echo ' <td>'.$row['email'].'</td>' ;
echo ' <td>'.$row['account_name'].'</td>' ;
echo ' <td>'.$row['user_type'].'</td>' ;
echo ' <td><button id="delete" type="button" class="btn btn-danger"><i class="far fa-trash-alt"></i></button>';
echo ' <button id="edit" type="button" class="btn btn-info"><i class="fas fa-user-edit"></i></button> </td>';
echo ' </tr>';
}
?>
</tbody>
</table>

You can do it this way:
php:
foreach($query as $row){
echo ' <tr>';
echo ' <td>'.$row['fname'].'</td>' ;
echo ' <td>'.$row['lname'].'</td>' ;
echo ' <td>'.$row['email'].'</td>' ;
echo ' <td>'.$row['account_name'].'</td>' ;
echo ' <td>'.$row['user_type'].'</td>' ;
echo ' <td><button data-id="' . $row['id'] . '" type="button" class="btn btn-danger delete"><i class="far fa-trash-alt"></i></button>';
echo ' <button type="button" class="btn btn-info edit"><i class="fas fa-user-edit"></i></button> </td>';
echo ' </tr>';
}
Jquery:
$("button.delete").each(function(){
$(this).on('click', function(e){
if (confirm("Are you sure you want to delete this user's account?")) {
$.ajax({
url: 'deleteUser.php?id='+$(this).data('id'),
success: function(data) {
toastr.danger("User successfully deleted!");
}
});
} else {
//do something else
}
});
});

HTML 4.01 specification says ID must be document-wide unique.
HTML 5 specification says the same thing but in other words. It says that ID must be unique in its home subtree, which is basically the document if we read the definition of it.
I'd fix that first: <button id="delete" needs to be unique
Next - I'd add an onClick to your delete button so you have <button onclick="deleteUser(2);"
Then, I'd rewrite your listener registration to just be a function:
function deleteUser(id){
if (confirm("Are you sure you want to delete this user's account?")) {
$.ajax({
url: 'deleteUser.php?id='+<?php echo $userID ?>,
success: function(data) {
toastr.danger("User successfully deleted!");
}
}

Related

TD contenteditable and update value in database

I have a table which i make the td's contenteditable, for the user to easily input the data needed.
Every rows and td have value of null in database. It will have value when the user will input something and it will save/update when button save is click
my php for tbody :
<?php
$emp_name = $_SESSION["emp_name"];
$month = $_SESSION["month"];
$REMARKS = $_SESSION[""];
$date_now = date('m');
$current_day = date('d');
$sample_var= $_SESSION["username"] ;
try {
$pdo = new PDO('mysql:host=localhost:3306;dbname=******;', '****', '*****' );
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$stmt = $pdo->prepare(
" SELECT * from tbl_assessment WHERE employeeName = '{$_SESSION['emp_name']}' "
);
$flag = $stmt->execute();
if ( !$flag ) {
$info = $stmt->errorInfo();
exit( $info[2] );
}
while ( $row = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
#$tbody1 .='<tr>';
$tbody1 .=' <input type="hidden" id="id" value="'.$_SESSION['id'].'"/> ';
$tbody1 .=' <input type="hidden" id="emp_name" value="'.$_SESSION['emp_name'].'"/> ';
$tbody1 .=' <input type="hidden" id="teamCode" value="'.$_SESSION['teamCode'].'"/> ';
$tbody1 .=' <input type="hidden" id="sectionCode" value="'.$_SESSION['sectionCode'].'"/> ';
$tbody1 .='<td style="height:30px" contenteditable>'.$row["date"].'</td>';
$tbody1 .='<td style="height:30px" contenteditable>'.$row["staffName"].'</td>';
$tbody1 .='<td style="height:30px" contenteditable>'.$row["findings"].'</td>';
$tbody1 .='<td style="height:30px" contenteditable>'.$row["action"].'</td>';
$tbody1 .='<td style="height:30px" contenteditable>'.$row["date_accomplished"].'</td>';
$tbody1 .='<td><button class="btn btn-warning px-2" id="btnSaveFindings" style="color:black;font-weight:bold;" title="Save"><i class="fas fa-save" aria-hidden="true"></i></button><button class="btn btn-info px-2" id="btnEdit" style="color:black;font-weight:bold;" title="Edit"><i class="fas fa-edit" aria-hidden="true"></i></button></td>';
#$tbody .='</tr>';
}
}
catch ( PDOException $e ) {
echo $e->getMessage();
$pdo = null;
}
?>
my html for table :
<div id="containerDiv" style="background-color:white;border-bottom:3px solid #ff6600;margin-left:50px;margin-right:50px;margin-bottom:140px;" class="animated fadeInUp">
<div class="" style="margin-left:15px;margin-right:15px;overflow-x:auto;" ><br>
<button class="btn btn-default px-3" style="float:right;" id="btnAddRow" name="btnAddRow" title="Add New row"><i class="fas fa-plus" aria-hidden="true"></i></button>
<table class="assessment" id="assessment" width="1526px" >
<thead style="background:-moz-linear-gradient( white, gray);">
<tr>
<th colspan="6" style="font-size:20px;">ASSESSMENT/FINDINGS:</th>
</tr>
<tr> <!---FIRST TABLE ROW--->
<th>DATE</th>
<th>NAME OF THE STAFF/S</th>
<th>ASSESSMENT/FINDINGS</th>
<th>ACTION TAKEN</th>
<th>DATE ACCOMPLISHED</th>
<th>ACTION</th>
</tr>
<tbody>
<?php echo $tbody1; ?>
</tbody>
</thead>
</table><br><br>
</div>
what would be the function of btnSaveFindings to update the value of td in database?
A few things to note,
Your query is not using a prepared statement - which is very simple with PDO; suggest you use that!
Your loop can generate multiple HTML elements with the same ID - this violates the uniqueness of an ID - if something can have the same ID, it can probably be a class instead.
When printing large blocks of HTML, its often better to exit PHP mode to print it where you need it.
To update the table, use jQuery with AJAX - assign classes to the different <td> elements, so we can fetch them with jQuery, and when you click the button, find the closest values of that row. Add a rows unique identifier to a data-* attribute of the button, so we know which row to update.
<?php
$emp_name = $_SESSION["emp_name"];
$month = $_SESSION["month"];
$REMARKS = $_SESSION[""];
$date_now = date('m');
$current_day = date('d');
$sample_var = $_SESSION["username"] ;
try {
$pdo = new PDO('mysql:host=localhost:3306;dbname=******;charset=utf8mb4', '****', '*****' );
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$stmt = $pdo->prepare("SELECT * FROM tbl_assessment WHERE employeeName = :employeeName");
$stmt->execute(['employeeName' => $_SESSION['emp_name']]);
?>
<script>
$(".btnSaveFindings").on("click", function() {
var id = $(this).data('assessment-id'),
row = $(this).closest("tr"),
date = $(row).find('.assessment-date')[0],
staffname = $(row).find('.assessment-staffname')[0],
findings = $(row).find('.assessment-findings')[0],
action = $(row).find('.assessment-action')[0],
accomplished = $(row).find('.assessment-date-accomplished')[0];
$.ajax({
type: "POST",
url: "updateRow.php",
data: {id: id,
date: date,
staffname: staffname,
findings: findings,
action: action,
accomplished: accomplished},
success: function(data) {
var status = data.status,
message = data.message;
alert(message);
}
});
});
</script>
<div id="containerDiv" style="background-color:white;border-bottom:3px solid #ff6600;margin-left:50px;margin-right:50px;margin-bottom:140px;" class="animated fadeInUp">
<div class="" style="margin-left:15px;margin-right:15px;overflow-x:auto;" ><br>
<button class="btn btn-default px-3" style="float:right;" id="btnAddRow" name="btnAddRow" title="Add New row"><i class="fas fa-plus" aria-hidden="true"></i></button>
<table class="assessment" id="assessment" width="1526px" >
<thead style="background:-moz-linear-gradient( white, gray);">
<tr>
<th colspan="6" style="font-size:20px;">ASSESSMENT/FINDINGS:</th>
</tr>
<tr> <!---FIRST TABLE ROW--->
<th>DATE</th>
<th>NAME OF THE STAFF/S</th>
<th>ASSESSMENT/FINDINGS</th>
<th>ACTION TAKEN</th>
<th>DATE ACCOMPLISHED</th>
<th>ACTION</th>
</tr>
<tbody>
<?php
while ($row = $stmt->fetch()) { ?>
<tr>
<td style="height:30px" class="assessment-date" contenteditable><?php echo $row["date"] ?></td>
<td style="height:30px" class="assessment-staffname" contenteditable><?php echo $row["staffName"]; ?></td>
<td style="height:30px" class="assessment-findings" contenteditable><?php echo $row["findings"]; ?></td>
<td style="height:30px" class="assessment-action" contenteditable><?php echo $row["action"]; ?></td>
<td style="height:30px" class="assessment-date-accomplished" contenteditable><?php echo $row["date_accomplished"]; ?></td>
<td>
<button class="btn btn-warning px-2 btnSaveFindings" style="color:black;font-weight:bold;" title="Save" data-assessment-id="<?php echo $row['id']; ?>">
<i class="fas fa-save" aria-hidden="true"></i>
</button>
<button class="btn btn-info px-2 btnEdit" style="color:black;font-weight:bold;" title="Edit">
<i class="fas fa-edit" aria-hidden="true"></i>
</button>
</td>
</tr>
<?php
}
?>
</tbody>
</thead>
</table>
<br />
<br />
</div>
<?php
} catch(PDOException $e) {
error_log($e->getMessage());
echo "An error occurred";
}
Then you need to create the file updateRow.php that runs the query.
<?php
header('Content-Type: application/json');
$pdo = new PDO('mysql:host=localhost:3306;dbname=******;charset=utf8mb4', '****', '*****' );
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
// See that the POST is sent
if (empty($_POST)) {
echo json_encode(['status' = false, 'message' => 'No data was sent. Update aborted']);
exit;
}
try {
$stmt = $pdo->prepare("UPDATE tbl_assessment
SET date = :date,
staffName = :staffName,
findings = :findings,
action = :action,
date_accomplished = :date_accomplished
WHERE id = :id");
$stmt->execute(['date' => $_POST['date'],
'staffName' => $_POST['staffName'],
'findings ' => $_POST['findings'],
'action ' => $_POST['action'],
'date_accomplished ' => $_POST['date_accomplished'],
'id ' => $_POST['id']]);
echo json_encode(['status' = true, 'message' => 'Update completed.']);
} catch (PDOException $e) {
error_log($e->getMessage());
echo json_encode(['status' = false, 'message' => 'An error occurred. Update failed.']);
}
As a final note, its often way better to use CSS classes on elements instead of inline styling. Makes for cleaner code, and more repeatable code.

I am getting same value of every button

i have fetch the data from database every thing work fine but problem is when i submit ajax request to test.php i got same value of every button
I am very week in Ajax and Java so please help me ,i am confuse how to get value of every button separately and submit to test.php file
<tbody>
<?php
$letter = mysqli_query($con,"SELECT * FROM letters order by id DESC");
if (mysqli_num_rows($letter) > 0) {
while ($rows_letter=mysqli_fetch_array($letter)) {
$id = $rows_letter['id'];
$subject = $rows_letter['subject'];
$status = $rows_letter['status'];
?>
<tr>
<th class="text-center" scope="row">1</th>
<td class="text-center"><?php echo $subject ;?></td>
<td class="text-center">
<?php
if ($status == 1) {
echo '<mark style="background-color: #5cb85c; color:white;"> Successfully Sent </mark>';
} else {
echo '<mark style="background-color:#f0ad4e; color:white;"> Not Sent Yet </mark>';
}
?>
</td>
<td>
<button type="button" class="btn btn-info btn-sm btn-block">
<span class="fa fa-pencil-square-o"></span> Edit</button>
</td>
<td>
<button type="button" class="btn btn-danger btn-sm btn-block">
<span class="fa fa-trash-o"></span> Move To Trash</button>
</td>
<td>
<button type="button" onclick="startsend();" id="id" value="<?php echo $id;?>"class="btn btn-success btn-sm btn-block">
<span class="fa fa-paper-plane-o"></span> Send To All</button>
</td>
</tr>
<?php
}
}
?>
</tbody>
<script type='text/javascript'>
//AJAX function
function startsend() {
var id = $('#id').val();
$.ajax({
type: "POST",
url: "test.php",
data:{ id: id
},
success: function(msg){
alert( "Button Id is " + msg );
}
});
}
</script>
and this is my test.php file
<?php
$id = $_POST['id']; echo $id;
//// rest of process according to id
?>
Try this, pass the id as param to ajax
Html:
<td><button type="button" onclick="startsend(<?php echo $id;?>);"
id="id" value="<?php echo $id;?>"class="btn btn-success btn-sm btn-block">
<span class="fa fa-paper-plane-o"></span> Send To All</button></td>
Ajax:
function startsend(id) {
$.ajax({
type: "POST",
url: "test.php",
data:{ id: id },
success: function(msg){
alert( "Button Id is " + msg );
}
});
}

Passing DB values to modal using jquery

I created a viewing module where users could view values from the database and I added an edit button, when you click the button, the modal should pop up with values based on the id.
Currently, this is what I'm getting when I click the edit button:
Now I'm still lacking one thing and it's the JavaScript which I already created:
<script>
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var recipient = button.data('whatever') // Extract info from data-* attributes
var modal = $(this);
var dataString = 'id=' + recipient;
$.ajax({
type: "GET",
url: "editdata.php",
data: dataString,
cache: false,
success: function (data) {
console.log(data);
modal.find('.dash').html(data);
},
error: function(err) {
console.log(err);
}
});
})
</script>
My fetch.php is purely PHP and I'm not sure how I would add the JS into it. Here's my fetch.php:
<?php
$connect = mysqli_connect("localhost", "root", "", "seatrequest");
$output = '';
$colors = array();
$colors["Ongoing"] = "red";
$colors["Closed"] = "#00FF00";
if(isset($_POST["query"]))
{
$search = mysqli_real_escape_string($connect, $_POST["query"]);
$query = "
SELECT * FROM request
WHERE req_date LIKE '%".$search."%'
OR reqname LIKE '%".$search."%'
OR natureofreq LIKE '%".$search."%'
OR postitle LIKE '%".$search."%'
OR critlevel LIKE '%".$search."%'
OR deadline LIKE '%".$search."%'
OR account LIKE '%".$search."%'
OR newaccname LIKE '%".$search."%'
OR lob LIKE '%".$search."%'
OR site LIKE '%".$search."%'
OR status LIKE '%".$search."%'
";
}
else
{
$query = "
SELECT * FROM request ORDER BY reqnumber";
}
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= '<div class="table-responsive">
<table class="table table bordered">
<tr>
<th style="background-color: #e6ecff;">Date Requested</th>
<th style="background-color: #e6ecff;">Requested By</th>
<th style="background-color: #e6ecff;">Nature of Request</th>
<th style="background-color: #e6ecff;">Position Title</th>
<th style="background-color: #e6ecff;">Critical Level</th>
<th style="background-color: #e6ecff;">Deadline</th>
<th style="background-color: #e6ecff;">Account</th>
<th style="background-color: #e6ecff;">Name of Account (For New Seat)</th>
<th style="background-color: #e6ecff;">LOB</th>
<th style="background-color: #e6ecff;">Site</th>
<th style="background-color: #e6ecff;">Status</th>
<th style="background-color: #e6ecff;">Action</th>
<th style="background-color: #e6ecff;">Edit</th>
</tr>';
while($row = mysqli_fetch_array($result))
{
$output .= '<tr>
<td>'.$row["req_date"].'</td>
<td>'.$row["reqname"].'</td>
<td>'.$row["natureofreq"].'</td>
<td>'.$row["postitle"].'</td>
<td>'.$row["critlevel"].'</td>
<td>'.$row["deadline"].'</td>
<td>'.$row["account"].'</td>
<td>'.$row["newaccname"].'</td>
<td>'.$row["lob"].'</td>
<td>'.$row["site"].'</td>
<td style="color:' . $colors[$row["status"]] . ';">' .$row["status"] . '</td>
<td>
<form method="post" action="update-work-status.php">
<input type="hidden" name="reqnumber" value="'.$row['reqnumber'].'" />
<button class="fa fa-check" style="color: green" type="submit" name="approve" value=""></button><button class="fa fa-close" style="color: red" type="submit" name="decline" value=""></button>
</form>
</td>
<td><a class="btn btn-small btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="'.$row['reqnumber'].' ">Edit</a></td>
</tr>
';
}
echo $output;
}
else
{
echo 'Data Not Found';
}
?>
I guess my question is how would I incorporate that JS inside fetch.php? I'm not really sure if it's gonna work after adding the JS but I'll find out.
Edit Modal
To pass data to your fetch.php from JS I'd create a data array and use the POST method like the following:
var dataString = {
id: recipient,
other: 'string'
}
$.ajax({
type: "POST",
url: "fetch.php",
data: dataString,
cache: false,
success: function (data) {
console.log(data);
modal.find('.dash').html(data);
},
error: function(err) {
console.log(err);
}
});
and in your php:
$id = $_POST['id'];
$other = $_POST['other'];
//Do something with your data
Let me know if that helps.

Modify table column data on button click

I am making a Leave Management System using PhP-Mysql.
I have a table which takes input from user while applying for their leaves.
(name, leavetype, fromdate, todate, supervisor, reason and status). Only the status column has a predefined value 'pending'.
Now I want to introduce two buttons (Accept/Reject) on each row. Which on click will change the value for Status field.
I am not sure how to do it, I have tried updating the table column but it updates only if there is a where Condition, which will not be the correct procedure for such case.
<div id="content">
<?php
$connect = new mysqli("127.0.0.1","root","","leavedb");
$sql = "SELECT
name,
leavetype,
fromdate,
todate,
supervisor,
reason,
DATEDIFF(todate,fromdate) as Days,
status as Status
FROM leavereq";
$result = $connect->query($sql);
?>
<table id="myTable">
<tr>
<th>Name</th>
<th>Leave Type</th>
<th>From Date</th>
<th>To Date</th>
<th>Supervisor</th>
<th>Reason</th>
<th>No. of Days</th>
<th>Status</th>
</tr>
<?php
while ($report=$result->fetch_assoc())
{
echo "<tr>";
echo "<td>".$report['name']."</td>";
echo "<td>".$report['leavetype']."</td>";
echo "<td>".$report['fromdate']."</td>";
echo "<td>".$report['todate']."</td>";
echo "<td>".$report['supervisor']."</td>";
echo "<td>".$report['reason']."</td>";
echo "<td>".$report['Days']."</td>";
echo "<td>".$report['Status']."</td>";
echo "<td>" . '<input type="submit" name="approve" value="Approve">' . "</td>";
echo "<td>" . '<input type="submit" name="reject" value="Reject">' . "</td>";
}
?>
</table>
</div>
//In the html : You have to add unique id for every <td> of status & also wants to change the input type of approve & reject...also require javascript
// check below
<script>
function function_name(status_id,req)
{
var status;
status='status'+status_id;
if(req=='approve')
{
document.getElementById(status).innerHTML='approve';
//pass ajax call to update entry in db
}
else if(req=='reject')
{
document.getElementById(status).innerHTML='reject';
//pass ajax call to update entry in db
}
</script>
<table id="myTable">
<tr>
<th>Name</th>
<th>Leave Type</th>
<th>From Date</th>
<th>To Date</th>
<th>Supervisor</th>
<th>Reason</th>
<th>No. of Days</th>
<th>Status</th>
</tr>
<?php
$i=0;
while ($report=$result->fetch_assoc())
{
echo "<tr>";
echo "<td>".$report['name']."</td>";
echo "<td>".$report['leavetype']."</td>";
echo "<td>".$report['fromdate']."</td>";
echo "<td>".$report['todate']."</td>";
echo "<td>".$report['supervisor']."</td>";
echo "<td>".$report['reason']."</td>";
echo "<td>".$report['Days']."</td>";
echo "<td id='status$i'>pending</td>";
echo "<td>" . '<button type="button" name="approve"'.$i.' onClick="return function_name($i,approve);">Approve</button>' . "</td>";
echo "<td>" . '<button type="button" name="reject"'.$i.' onClick="return function_name($i,reject);">Reject</button>' . "</td>";
$i++;
}
?>
</table>

Javascript in Codeigniter

I have the following code to add, edit and delete user. Add function works fine but edit and delete functions are not working. I'm not sure where it goes wrong.
application/view/userlist.php
<script type="text/javascript">
var oTable;
$(document).ready(function()
{
oTable = $('#userListTable').dataTable( {
"iDisplayLength": 25,
"aLengthMenu": [5,10,25,50,100],
"aoColumns": [ {
"bSortable": false },
null,
null,
null,
null,
null,
null,
null,
null, {
"bSortable": false } ]
});
oTable.fnSort( [ [1,'asc'] ] );
});
function removeUser()
{
var ids = '';
$("input:checked", oTable.fnGetNodes()).each(function(){
if (ids == '') {
ids += $(this).val();
}else{
ids += ','+$(this).val();
}
});
var url = "<?php echo base_url(); ?>Admin/userRemove/";
var form = $('<form action="' + url + '" method="post">' +
'<input type="text" name="ids" value="' + ids + '" />' +
'</form>');
console.log(form);
$('body').append(form);
if (ids != '') {
form.submit();
}else{
alert('Select user to remove');
}
}
</script>
//some codes here
<button type="button" data-hover="tooltip" onclick="removeUser()" title="Delete Selected" class="btn btn-default">
<i class="fa fa-eraser"></i>
</button>
<button type="button" data-hover="tooltip" title="Add New User" class="btn btn-default">
<div class="panel-header" data-toggle="modal" data-target="#myModal">
<i class="fa fa-user-plus fa-1x"></i>
</div>
</button>
// #myModal codes here
<script type="text/javascript">
$(document).ready(function(){
$('.edit-row').live('click',function(){
var me = $(this);
var editModal = $('#myModalEdit');
editModal.find('#userID').val(me.attr('data-userID'));
editModal.find('#userName').val(me.attr('data-userName'));
editModal.find('#userFullName').val(me.attr('data-userFullName'));
editModal.find('#userPass').val(me.attr('data-userPass'));
editModal.find('#userEmail').val(me.attr('data-userEmail'));
$('#myModalEdit').modal('show');
});
});
</script>
//#myModalEdit codes here
<table id="userListTable" class="table table-hover table-striped table-bordered" >
<thead>
<tr>
<th><center><strong>#</strong></center></th>
<th><h4><strong>USER ID</strong></h4></th>
<th><h4><strong>FULL NAME</strong></h4></th>
<th><h4><strong>USERNAME</strong></h4></th>
<th><h4><strong>EMAIL</strong></h4></th>
</tr>
</thead>
<tbody>
<?php
if(!empty($data_user)):
foreach($data_user as $row)
{
echo '<tr>
<td class="text-center">
<input type="checkbox" name="selectAction" value="'.$row->userID.'" unchecked>
</td>';
echo '<td>'.$row->userID.'</td>';
?>
<td><a class="edit-row" href="javascript:"
data-userID="<?php echo $row->userID; ?>"
data-userFullName="<?php echo $row->userFullName; ?>"
data-userName="<?php echo $row->userName; ?>"
data-userEmail="<?php echo $row->userEmail; ?>"
>
<?php echo $row->userFullName; ?>
</a>
</td>
<?php
echo '<td>'.$row->userName.'</td>';
echo '<td>'.$row->userEmail.'</td>';
echo '</tr>';
}
endif;
?>
</tbody>
</thead>
</table>
// other codes
application/controllers/Admin.php
public function userRemove() {
$ids = $this->input->post('ids');
if (!empty($ids)) {
$this->db->where('userID IN (' . $this->input->post('ids') . ')')
->
delete('user_tbl', $data);
}
redirect('userlist', 'refresh');
}
Edit and delete functions seems not working..

Categories

Resources