0

I have problem in code for IF statement.
Im looking in a mysql table if there is a field (fld_comleted) that has record with "NO" in it.

If there is a record that has "NO" in it it has to do something (send email to client) if there is no records marked "NO" it should not do anything.

my code looks like this:

<?php

include_once "connect_to_mysql.php";

$extract = mysql_query("select * from tbl_data WHERE fld_sent='NO'");
		while ($row = mysql_fetch_assoc($extract))
		{
		$mailid = $row['id'];
		$mail = $row['fld_data'];
		$sent = $row['fld_sent'];
		}

if ($sent=="NO")

$mail_body = "We have drawn a prize, please visit mysite.com to see if you have won;
$subject = "Prize Drawn";
$headers  = "From:prizes@smyite.com\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "Disposition-Notification-To: $mail";

$mail_result = mail($to, $subject, $mail_body, $headers);
					
echo "Mail sent";
echo "<br>";
echo $newsid;
						
						
mysql_query("UPDATE tbl_data SET received='1' WHERE email='$email' LIMIT 1");


elseif ($sent=="")

echo "DO NOTHING HERE BECAUSE IT HAS NOT FOUND ANY DATA";

?>
1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by branding4you
0

ah solved it :)

moved the variales to only populate after the IF

<?php

include_once "connect_to_mysql.php";

$extract = mysql_query("select * from tbl_data WHERE fld_sent='NO'");
		while ($row = mysql_fetch_assoc($extract))
		{

if ($sent=="NO")

                  $mailid = $row['id'];
		$mail = $row['fld_newsdata'];
		$sent = $row['fld_sent'];
		}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.