bradkenyon Posted July 10, 2008 Share Posted July 10, 2008 i want to only display today's events, based on m/d/y using the date function $today = date("m/d/y"); $query = "SELECT * FROM calendar_items WHERE date('m/d/y',strtotime(expiredate)) = $today"; expiredate is the column in the table which it holds the date it is held on, and i want to only display the events for that day to display. so it automatically displays the days events according to today's date. i bet i am going entirely in the wrong direction, but any help is appreciated. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 10, 2008 Share Posted July 10, 2008 SELECT * FROM calendar_items WHERE expiredate = CURDATE() Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted July 10, 2008 Author Share Posted July 10, 2008 the expiredate is formatted as: for example: 2008-09-11 12:30:00 so i don't know if CURDATE will do the trick. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 10, 2008 Share Posted July 10, 2008 in which case SELECT * FROM calendar_items WHERE DATE(expiredate) = CURDATE() Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted July 10, 2008 Author Share Posted July 10, 2008 still not working. today there is an event, but it doesn't send anything, today's event expiredate is: 2008-07-10 11:35:00 here is all the code. <?php require_once("../customemailer/htmlMimeMail.php"); include('../cgi-bin/newsinclude/db.php'); //date("m/d/y",strtotime($row['expiredate']) $query = "SELECT * FROM calendar_items WHERE DATE(expiredate) = CURDATE()"; //$query = "SELECT * FROM calendar_items WHERE expiredate > NOW() ORDER BY expiredate"; $result=mysql_query($query); if($result) { ?> <ul> <? while($row = mysql_fetch_array($result)) { $i = 0; $t = 1; while($i <=0) { print '<p><strong>'.date("m/d/y",strtotime($row['expiredate'])).'</strong> - <a href="/events/?id='.$row['id'].'">'.$row['subj'].'</a> - <small>'.$row['location'].'</small></p>'; //$message.= date("m/d/y",strtotime($row['expiredate']))."\t".$row['subj']."\t".$row['location']."\r\t\t".$row['body']."\r\r"; $message.= $row['subj']."\t".$row['location']."\r".$row['body']."\r---------------------------------------------------------------------------------------------------------\r\r"; $i++; $t++; } } $email = 'no-reply@domain.com'; $mail = new htmlMimeMail(); $mail->setText($message); $mail->setSubject('Faculty/Staff Events'); /** * Sends the message. */ $mail->setFrom($email); $result = $mail->send(array('morsebk@herkimer.edu')); //echo $result ? 'Mail sent!' : 'Failed to send mail'; } else { print 'There are no events.'; } ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted July 10, 2008 Share Posted July 10, 2008 Have you tried running the query from the mysql command line? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.