查看MySql的PHP IF语句

Sorry, I should have put more information in the question

I am trying to figure out how to create a if statement that looks at a mysql field for example: if date ("D") = mysqlDateField

I have a small site that users put reminders into a forum to be sent to a specified email address on days they setup.

The days are stored in a mysql database in mon, tue, wed, etc. format.

The users can select multiple days so I have a field for each day (not sure if that is the best way to do it or not)

so I have a sendmail script that runs and sends out the emails with the reminders the users specified.

I want the if statement to check the current day against the day in the database

I am using the date ("D") format currently since it matched what wa stored in the database

After looking around the different forums and w3schools I came up with this below but it is not working, I am new to php and mysql and not exactly sure how to get it working the way I want

$result = mysql_query("SELECT * FROM users")or die(mysql_error());
$d = date ("D");

if (mysql_num_rows($result)==$d)

Thanks

Some little note before the code sample:

  • creating a date to compare with D is bad, use some more useful format like 'Ymd';
  • the date you're going to compare must be in the same format (you should not compare a ymd with a ymdhis date) becouse else they will give you inconsistent result. Convert or format the date before using them.
  • you are receiving a lot of result via wildcard query on tables, you should avoid when possible a SELECT *

    foreach($result as $row){    
        if(strtotime($row['field_with_date']) == strtotime($d)){ } }