I can successfully extract the data from the database however am having trouble now deleting a specific row using the checkbox method.
I have used a number of different tutorials including previous posts here but it’s still not there.
Here is my code:
<div id="content">
<h1>Post Bulletin</h1>
<br />
<form action="insert.php" method="post">
<label for="title">Title</label>
<br />
<input type="title" name="title" id="file" required="required" placeholder="Bulletin Title" />
<br />
<br />
<label for="bulletin">Bulletin</label>
<br />
<textarea id="bulletin" name="bulletin" id="bulletin" rows="10" cols="50" required="required" placeholder="Bulletin Message"></textarea>
<br />
<input type="submit" />
</form>
<br/ >
<br/ >
<h3>Current Bulletin Posts</h3>
<?php
require('connect.php');
$data = mysql_query("SELECT * FROM bulletins ORDER BY Date_Entered DESC")
OR die("Can't access bulletins table. " . "<br />". mysql_error());
while($info = mysql_fetch_array($data))
{
Echo "<br />" . "Delete: " . "<input name='checkbox[]' type='checkbox' id='checkbox'/>" . "<br />" . "<br />";
Echo $info['Title'] . "<br />" . "<br />";
Echo $info['Bulletin'] . "<br />" . "<br />";
Echo "Posted at " . $info['Date_Entered'] . "<br />" . "<br />";
Echo "<hr>";
}
?>
I have created the checkbox but am unable to process the deletion.
Am I right in thinking that a ‘if isset’ statement would suffice? How would I assign a ID to the array of checkbox?
Use the row ID as the checkbox’s
value, this is what will be submitted to the PHP side.Now, on the PHP side, you will receive the record ID’s to delete as an array in
$_POST['delete'].Also your checkboxes must be contained within a form for them to be submitted.