deleteing an array
Posted: Mon Sep 15, 2003 10:47 am
Hey
Trying to delete multiple records from my database. I use checkboxs and tick which ones i want to delete (approve.php). I press the delete key, and a confirm page shows (confirm.php). It does not delete the records or record.
approve.php
I tested it so when it passes throught to confirm.php it echos the advert_id which it does work.
But if i click on yes to confirm it does not delete
confirm.php
When i click on yes, it does not seem to pass the advert_id through.
Can any one help?
Many thanks
Trying to delete multiple records from my database. I use checkboxs and tick which ones i want to delete (approve.php). I press the delete key, and a confirm page shows (confirm.php). It does not delete the records or record.
approve.php
Code: Select all
<?php
<form name="delete" method="post" action="delad.php">
<input type="Submit" name="submitdel" value="Delete">
<input type="Checkbox" name="advert_id[]" value="<?php echo $advert_id ?>">
?>I tested it so when it passes throught to confirm.php it echos the advert_id which it does work.
But if i click on yes to confirm it does not delete
confirm.php
Code: Select all
<?php
ob_start();
$advert = $_POST['advert_id'];
echo $advert[$x];
if (isset($_POST['no'])) {
header( "Location: approve.php" );}
if (isset($_POST['yes'])) {
for ($x=0; $x<sizeof($advert); $x++)
{
$query = "delete from advert where advert_id = '$advert[$x]'";
mysql_query($query,$db);
}
mysql_close($db);}
header("Location: approve.php");
?>
<form name="delete" action="<?php $PHP_SELF ?>" method="post">
<input type="submit" name="yes" value="Yes">
<input type="submit" name="no" value="No">
</form>
<?php
ob_end_flush();
?>When i click on yes, it does not seem to pass the advert_id through.
Can any one help?
Many thanks