i want to delete a row of data for example userid number 4 when i click on the delete button but nothing happen.It just pop out "Are you sure you want to delete '4undefine" Can someone help?
index.php
<?php
$connection = mysqli_connect("localhost","root","","userdatabase");
mysqli_select_db($connection, "userdatabase");
$sql_query="SELECT * FROM user";
$result_set=mysqli_query($connection,$sql_query);
if(isset($_GET['delete_id']))
{
$sql_query="DELETE FROM user WHERE userid=".$_GET['delete_id'];
mysqli_query($sql_query);
header("Location: $_SERVER[PHP_SELF]");
}
?>
This is the confirmation
<script type="text/javascript">
function delete_id(userid,username,password,email,workplace,role)
{
if(confirm("Are you sure you want to delete '" +userid+username))
{
window.location.href='adminhome.php?delete_id='+userid;
}
}
</script>
<?php
if(mysqli_num_rows($result_set)>0)
{
while($row=mysqli_fetch_row($result_set))
{
$userid = $row[0];
$username = $row[1];
$password = $row[2];
$email = $row[3];
$workplace = $row[4];
$role = $row[5];
?>
<tr>
<td><?php echo $userid; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $password; ?></td>
<td><?php echo $email; ?></td>
<td><?php echo $workplace; ?></td>
<td><?php echo $role; ?></td>
<td align="center"><a href="javascript:delete_id(<?php echo $row[0]; ?>)"><img src="RemoveUser.png" alt="Delete" /></a></td>
</tr>
<?php
}
}