I have a mysql database that has a column named datestamp which is varchar(30) and the values in this field are stored as a date example 09/06/2011 Im trying to display data in the database only if the current date is equal to today's date. And im having some difficulties getting this to work. I was able to do this when i had the column set as a datetime but i do not like this column function there for i changed it. Any help that anyone can provide would be greatly appreciated. Im new to php and still have alot to learn. below is the php function that im trying to display. <?php $myDate = CURRENT('m/d/y'); $result = mysql_query("SELECT * FROM eattendance WHERE datestamp = $myDate "); echo "<table border='1' align='center'> <tr> <th>Name</th> <th>Date Entered</th> <th>Entered By</th> <th>Reason</th> </tr>"; .......more code ?> the rest of the code just displays the values from the database in the format of a table that is positioned in the middle of a php page.
echo the value of $myDate and see what's really going into that variable. This works for me : $myDate = date("m/d/y"); echo $myDate; $db = mysql_connect('localhost','user','pwd'); mysql_select_db('test'); $res = mysql_query("SELECT * FROM test WHERE datestamp='$myDate'"); $row = mysql_fetch_array($res); PHP:
Hey shallowink, That work for me and believe it or not i had that originally but didn't realize that the dates in my database where set as 09/07/2011 and the $mydate value is using the format of 09/07/11 so i appreciate your input and yeah probably would have caught that if my head wasn't so congested