just have the user click the button and with the form, you will need to use $POST['dname']; or $GET['dname']; to access the value
note: using the name may be risky as their might be cases where there is more that one user with that name....better to use the rowid or some other unique identifier for the row to remove the data
<?
//check to see if the page was submitted
if (!$submit){ //ie the delete button was not hit
//show form with data
$sql="select * from table";
$result=mysql_query($sql) or die ("could not connect");
if (!$result){
echo "no data found";
die();
}else{
echo "<html><body><form name=\'deletion\'
action="PHP_SELF" method=\'post\'>
<select name=\'dname\'>";
while ($rows=mysql_fetch_array($result){
$row = $rows['userID'];
$name=$rows['username'];
echo "<option value=\'$row\'>$name</option>";
}
echo "<input type=\'submit\' value=\'delete\'>
</form></body></html>";
}else{ //the delete button was hit
if(!$POST['dname']{
echo "no valid value recorded. try again";
die();
}else{
$sql2="delete from table where rowID = $POST['dname']";
$result2=mysql_query($sql2) or die ("couldn't connect");
if(!$result2){
echo "delete failed. try again";
die();
}else{
echo "user deleted";
die();
}
}
?>
hth