I have displayed an html table with user information for admin viewing. I created a link/icon to delete the specific user(row) but i am receiving a 500 internal server error.
Their is another similar question on here that got me pretty far but i am still receiving errors
My table:
$query = "SELECT zone, firstname, lastname, email, business, reg_date, phone FROM UserList";
// Display users is a table format
$result = $conn->query($query);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td> " . $row["zone"]. "</td><td> " . $row["firstname"]. "</td><td> " . $row["lastname"] . "</td><td> " . $row["email"]. "</td><td> " . $row["business"]. "</td><td> " . $row["reg_date"]. " <a class='deleteRow' id='.$row->id.' href=''><i class='fa fa-times' aria-hidden='true'></a></td></i></tr><br> ";
}
} else {
echo "<div class='no_results'>No Users Added</div>";
}
My jQuery/Ajax:
$(function(){
$(document).on('click','.deleteRow',function(){
var del_id= $(this).attr('id');
var $ele = $(this).parent().parent();
$.ajax({
type:'POST',
url:'removeUser.php',
data:{'del_id':del_id},
success: function(data){
if(data=="YES"){
$ele.fadeOut().remove();
}else{
alert("can't delete the row")
}
}
});
});
});
My removeUser file:
<?php
include('config.php');
$user_id = $_POST['del_id'];
//echo $user_id
$qry = "DELETE FROM UserList WHERE id = '$user_id'";
$result = mysql_query($qry);
if(isset($result)) {
echo "YES";
} else {
echo "NO";
}
?>
Why am i getting a 500 internal server error and how can i fix it? Thanks.