Hi all, this is really geting to me now, I jsut keep going round in circles and getting nowhere.
I have a form with multiple radio buttons, each button represents a category of reptile. When you choose one of the radio buttons you are taken to a page for that category which displays all the entries for that category that have been stored in a mysql table with a checkbox beside each entry. When I check one and hit the 'Remove' button it always removes the oldest entry in the table and not the one corresponding to the check box that was checked.
I need it to remoe all the checked entries, so say, if 6 were checked then that 6 will be removed from the table.
I really need help on this if anyone has the time.
Cheers.
My remove.php file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Stocklist update</title>
<link href="../css/gallery_submit.css" rel="stylesheet" type="text/css" />
<link href="../css/removestock.css" rel="stylesheet" type="text/css" />
<link href="../css/template.css" rel="stylesheet" type="text/css" />
<body>
<?php
include 'connect.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['next']))
{
$selected_radio = $_POST['delete'];
echo '<h2><b>Boids</b></h2>';
?>
<form class='form' action='remove2.php' method='post' enctype='multipart/form-data' name='stockupdate_form' id='stockupdate_form' style='margin-bottom:0px;'>;
<?php
if ($selected_radio == 'Boids')
{
$data = mysql_query("SELECT * FROM boids ORDER BY id DESC")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
echo "<span class='span2'>";
echo $info['species'];
echo ' : ';
echo $info['year'];
echo ' : ';
echo $info['sex'];
echo ' : ';
echo '£';
echo $info['price'];
echo "<input type='checkbox' name='check[]' />";
echo '<br />';
echo "</span>";
}
}
}
}
?>
<input type='submit' name='remove' value='Remove' />
</form>
</body>
</html>
My remove2.php file
<?php
include 'connect.php';
if ( isset($_POST['remove']))
{
$data = mysql_query("SELECT * FROM boids")
or die(mysql_error());
$info = mysql_fetch_array( $data );
$id=$info['id'];
$sql = mysql_query("DELETE FROM boids WHERE id = $id");
while($info = mysql_fetch_array( $data ))
{
echo "<span class='span2'>";
echo $info['species'];
echo ' : ';
echo $info['year'];
echo ' : ';
echo $info['sex'];
echo ' : ';
echo '£';
echo $info['price'];
echo '<br />';
echo "</span>";
}
}
?>
Thanks for looking.................