Folks,

Here is a php code that lists all the rows and columns in your mysql tbl for you to select the rows (via check boxes) you want to delete and then delete them by clicking the appropriate "delete" buttons. Problem is, when I click any of the "delete" buttons, I get error flicking for a sec that there is an undefined variable $num. Not sure where to define it and how.
Confesssion
I actually play-paused 2 youtube videos and copy typed the code you see. That is one way I learn and gain a little work experience. Was not aware that the "each" function was deprecated until another told me.
Even though, I checked the foreach loop tutorial, here I am at a loss how to make use of it. Feeling flabbergasted in my failure!

Code:
<?php
session_start();
require "conn.php";
require "site_details.php"; ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Follow Users</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form" action="" method="post">
<table border=1 cellpadding=1 cellspacing=1>
	<tr>
		<th>Id</th>
		<th>Username</th>
		<th>Password</th>
		<th>Email</th>
		<th>Delete</th>
	</tr>
<?php
$res=mysqli_query($conn,"SELECT * FROM users");
while($row=mysqli_fetch_array($res))
{
	echo "<tr>";
	echo "<td>"; echo $row["ids"]; ?> <input type="checkbox" name="num[]" class="other" value="<?php echo $row["ids"]; ?>" /> <?php echo "</td>";
	echo "<td>"; echo $row["usernames"]; "</td>";
	echo "<td>"; echo $row["passwords"]; "</td>";
	echo "<td>"; echo $row["emails"]; "</td>";
	echo "<td>"; echo "<input type='submit' name='submit' value='delete selected'>"; "</td>";
	echo "</tr>";
}
?>
</table>
</form>
<?php
if(isset($_POST["submit"]))
{
   $box=$_POST['num'];
   while (list ($key,$val) = @each ($box))
	{
      mysqli_query($conn,"DELETE FROM users WHERE id='$val'");
    }
?>
       <script type="text/javascript">
       window.location.href=window.location.href;
       </script>
<?php
}
?>

</body>
</html>
Here's another one. But, this one does not have the DELETE BUTTON. DELETE LINK instead. Same problem I'm facing on this one too. Not deleting anything.

Code:
<?php
session_start();
require "conn.php";
require "site_details.php"; ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Follow Users</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table border=1 cellpadding=1 cellspacing=1>
	<tr>
		<th>Id</th>
		<th>Username</th>
		<th>Password</th>
		<th>Email</th>
		<th>Delete</th>
	</tr>
<?php 
$sql = "SELECT * FROM users";
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result))
	{
		echo "<tr>";
		echo "<td>".$row['ids']."</td>";
		echo "<td>".$row['usernames']."</td>";
		echo "<td>".$row['passwords']."</td>";
		echo "<td>".$row['emails']."</td>";
		echo "<td><a href=delete2a.php?id=".$row['ids'].">Delete</a></td>";
	}

?>
</table>
</body>
</html>
Can some good Samaritan fix the 2 codes so we beginners can learn from your examples ?
I've come this far on these 2. Don't want to quit at the end.

Cheers!