Okay, so instead of the ID's of each record showing up in the form that is displayed for the user, there are radio buttons. I want to create it as when the user clicks on one of the radio buttons, that record is selected. Then the user, clicks on the delete button and gets redirected to another page in which it displayes the content of that record.
First Name: (value of first name in record)
Last Name: (value of last name in record)
And then there will be a button on the bottom that says, Confirm delete. And then when the user clicks that button, the record will get deleted.
I just don't know how to use the radio buttons that contain the ID of each record to do this..
echo "<tr><td><input type='radio' name='idselect' value=".$row["ID"]." /></td>
That's how i put the radio buttons, as the value being the ID of the record from my database. I also created a variable:
But i don't think this is the right way, then I passed that variable to the 'confirm' page.
@$id_select=$_POST['idselect']; If ($record_action=='Delete') echo "<h1> Delete Record </h1>"; $db=mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("project6",$db) or die (mysql_error()); $SQL="SELECT * FROM 'contacts' WHERE ID='$id_select'"; $result=mysql_query($SQL) or die(mysql_error()); $num_results=mysql_num_rows($result); $row=mysql_fetch_array($result); echo "".$row["ID"]."".$row["First_Name"]."".$row["Last_Name"]."".$row["Address"]""; mysql_close($db)
Don't mind the record_action stuff. But I don't know how to get the value of the record from the user just pressing the radio button that contains the ID. As you can see, I was trying to display the record that the user had selected.