I have a database that has 2 records in it:
id | message | date | user | option
---+-----------+-------------+-----------+--------
1 | Welcome | 2015-03-01 | | 0
2 | message | 2015-03-05 | admin | 0
What I'm trying to do is if the user field is blank, it shows the message to all users, if there is a username (such as admin in this example) listed, it shows the one for that user, and a the blank message if it exist.
Right now it will show both messages if the user is Pam (it should only show id 1).
If the user is admin, it shows both messages.
It seems like its ignoring the user = '$zuser'
What am I doing wrong?
<?php
ini_set('display_errors',1); error_reporting(E_ALL);
$zuser=$_COOKIE['aauser'];
$result = mysqli_query($con,"SELECT * FROM message WHERE (user = '$zuser' OR run_date >= CURDATE() AND user='')");
while($quick = mysqli_fetch_array($result))
{
echo $quick['message'];
echo '<script>alert("'.$quick['message'].'");</script>';
}
?>
or die(mysqli_error($con))tomysqli_query()nulland'' (empty string)if(isset($_COOKIE['aauser'])){...}that will determine if it's set. Orif(!empty($_COOKIE['aauser'])){...}