I have an array the inputs the user name in a table, however it loops thru all the names and inputs each one into the table. I need help figuring out how to do just the one selected.
I have a list of names which is displayed after it loops thru an array, this list can be endless
John
Jen
Betty
With each name is a link you click to "block" that person from appearing on the list again
Code for that
<input type='hidden' name='block2[]' value='$id' />
<input type='image' value='Block' src='delete.png' title='Block'>
goes here to be processed
$my_array2 = $_POST['block2'];
if($_POST['block2']){
$totalIDs = count($my_array2);
for ( $i=0; $i < $totalIDs; $i++ ) {
$sql2 = mysql_query("SELECT sender FROM nudges WHERE id='$my_array2[$i]'");
while($r = mysql_fetch_array($sql2)) {
$sender=$r['sender'];
$query2 = ("INSERT INTO blockUser VALUES(NULL,'$clientID','$sender')");
$result2 = mysql_query($query2) or die(mysql_error());
} // END while
} // END for
} // END if($_POST['block2'])
However it loops thru every name on the page and inputs that into the db, I know that is does this due to the loop.
My problem is I cannot figure out how to code it to only do the 1 name, you will only be able to click on 1 name at a time.
Please help!