I need to delete some data from mysql. I know a bit of php but get really lost with mysql and really don't want to mess this up... I did make a .sql backup but I need to get this right. That's why i'm posting the question here. I know I will get some crap for not trying myself and posting my code here but to be hosnest.. this is as far as I got before I got stuck:
<?php
$con = mysql_connect("localhost","USERNAME","PASSWORD");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DATABASE", $con);
$result = mysql_query("SELECT * FROM subscriber");
while($row = mysql_fetch_array($result))
{
echo $row['mail'] . " " . $row['snid'];
echo "<br />";
}
mysql_close($con);
?>
What i'm really trying to do is this:
- Locate all rows where
status
=0
the in the table calledsubscription
and get the fieldsnid
(which is an integer) - Then go to the table called
subscriber
and delete the row with the matchingsnid
(also a field in this tables row) - Then go back to
subscription
and delete the original matched row
Does this make sence?.... I've done my own head in just trying to explain it :(