Hello All,
I am trying to delete multiple records from a form variable entered in text box field. (Variable = domain) So enter one domain per line in text field that you want to delete.
This is the code I have for my form processing. Which is basically the same code I use for inserting the domains from a text box field only to delete verses insert.
<?php
require('config.php');
$urlsplit = preg_split("/\n+/", $domain);
foreach ($urlsplit as $key => $value) {
$query = mysql_query("SELECT url FROM collection WHERE url='$value'");
if (mysql_num_rows($query) < 0)
unset($urlsplit[$key]);
}
$a = count($urlsplit);
sort($urlsplit);
$sql = "SELECT url FROM collection";
$res = mysql_query($sql);
$i = 0;
while ($a > $i) {
$sqlquery = "DELETE FROM collection WHERE url='$value' ";
$result = mysql_query($sqlquery);
$i++;
}
if ($result) {
print "<b><font color=red>$a</font> Domains</b><br><br>\n";
print "<b>Have been Successfully Deleted</b><br><br>";
} else {
print "<b>Domains NOT Deleted. Please Report This Error <br>";
echo mysql_error();
}
?>
I dont get any errors with this. It just doesnt delete anything.
Any help is greatly appreciated.
Perhaps I am going about this wrong ?? If there is a better way I would appreciate some samples.
Thanks