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";

?>

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'];
		}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.