Okay, so instead of the ID's of each record showing up in the form that is dosplayed 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.
For example:

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..

Member Avatar for diafol

Are you sure you want radiobuttons or checkboxes?

Anyway, as you create your set of radiobuttons, use the 'id' from the DB table as the 'value' of the radiobutton as you loop over all the records available for deletion:

$rads = "<table><thead><tr><th>...other headings...</th><th>Delete</th><tr></thead><tbody>";
while($d = mysql_fetch_array($result)){
  $rads .= "<tr><td>...rest of table...</td><td><input type=\"radio\" name=\"deletes\" value=\"{$d['id']}\" /></td></tr>";
} 
$rads .= "</tbody></table>";

Something like that?

You just pick up the value in another page with $_POST. Clean this variable and then use it to extract the relevant record from the DB. Show it and add a confirm delete button. You can use a hidden field to hold the 'soon-to-be-deleted' id of the record. The confirm delete button sends the id value to a page that picks it up via something like $_POST;

I don't fully understand.

My code is like this:

<table border="1" />
<th>ID</th> <th> First Name </th> <th>Last Name </th> <th> Address </th> <th> Postal code </th> <th>Phone</th> <th>E-mail Address</th><th> City </th><th>Province</th> 

<?php
@$record_action=$_POST['select'];
@$id_select=$_POST['idselect'];

$db=mysql_connect("localhost","root") or die(mysql_error());
					
mysql_select_db("project6",$db) or die (mysql_error());
$SQL="SELECT * 

FROM  `contacts` 

INNER JOIN cities ON contacts.citiesID = cities.citiesID

ORDER BY contacts.Last_Name";
$result=mysql_query($SQL) or die(mysql_error());
$num_results=mysql_num_rows($result);

					
for ($i=0;$i<$num_results;$i++)

{

$row=mysql_fetch_array($result);

 echo "<tr><td><input type='radio' name='idselect' value='".$row["ID"]."' /></td><td>".$row["First_Name"]."</td><td>".$row["Last_Name"]."</td><td>".$row["Address"]."</td><td>".$row["Postal_Code"]."</td><td>".$row["Phone"]."</td><td>".$row["Email_Address"]."</td><td>".$row["Name"]."</td><td>".$row["Province"]."</td></tr>";

}
 mysql_close($db);

?>
</table>
<form name="addform" action="p06_form.php" method="POST">

<input type='submit' name='select' value='Add' /><br/>

</form>

<form name="deleteform" action="p06_confirm.php" method="POST">
<input type='submit' name='select' value='Delete' /><br/>

<?php echo "&nbsp"; ?><br/>

<input type='submit' name='select' value='Edit' /><br/>
</form>

The user has to select the record they wish to delete by clicking the radio button and clicking the delete button. Then they will get redirected to another form in which the record that they have selected with be displayed with a button below saying "confirm delete" or something. I just don't know how to display the selected record in the next page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.