Why do you select them all? Just run the delete query. The logic here is a little questionable but I'll assume you want to know the information so try something like:
<?php
// Variables are case-sensitive, most prefer lowercase
// but maybe you really want ID and not id.
if (@is_numeric($_REQUEST['id'])) {
$id = $_REQUEST['id'];
} else {
print "Please go back and choose an appropriate user id";
exit;
}
if (!$conn = @mysql_connect($host, $username, $password)) {
print "Could not connect to mysql : " . mysql_error();
exit;
}
if (!@mysql_select_db($dbname, $conn)) {
print "Could not select the db ($dbname) " . mysql_error();
exit;
}
$sql = "SELECT id,name FROM yourtable WHERE id = $id";
if (!$result = @mysql_query($sql)) {
print "Could not run query ($sql) : " . mysql_error();
exit;
}
// If there is a row of data with that id
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
extract($row);
print "Hello, we are about to delete the information from id $id, so say goodbye to $name, s/he will be gone forever! RIP.";
$sql = "DELETE FROM yourtable WHERE id = $id";
if (!$result = mysql_query($sql)) {
print "Could not run query ($sql) : " . mysql_error();
exit;
}
// This should always return true but hey let's go with it
if (mysql_affected_rows($result) > 0) {
print "Okay, $name is officially gone now! :)";
}
} else {
print "There is nobody with that id here";
}
That of course is just an example on what you can do, it needs some work (like the error handling). But the point is I strongly suggest not looping through almost every record like that, what's the point?
See also: http://www.w3schools.com/sql/