PDA

View Full Version : code checks first entry only !!!


vosgien
07-05-2003, 09:11 AM
Hi,
I have been trying to set up some code to check entries in a db like this :

<?
include("connected.php");

$query = "SELECT firstname,email FROM $table WHERE TO_DAYS(NOW()) - TO_DAYS(entryDate) >= 1";/*set to 1 for testing*/
$result = mysql_query($query);
if (mysql_num_rows($result))
{
while ($row = mysql_fetch_array($result))
{
$name = $row['firstname'];
$email = $row['email'];
/*code to send an email*/

$query ="DELETE FROM $table WHERE email = '$email'";
$result=mysql_query($query);
exit;

}
}
/* Close link to MySQL */
mysql_close($link);
?>
It works in that it sends the email and deletes the entry, but only the first enty in the db. I need it to check all entries and delete all entries that match the $query.
The code is fired once a day by a cron.
I think I may need to use for each...., however despite a search at the on line mysql manual I cannot work out how or where to use it, or even if it is the right thing to do.
Can anyone help me with this please ?

Vosgien

Billy T
07-05-2003, 03:20 PM
could it be the

exit;

?