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. Link to comment https://forums.phpfreaks.com/topic/114130-only-display-todays-events-from-table/ Share on other sites More sharing options...
Barand Posted July 10, 2008 Share Posted July 10, 2008 SELECT * FROM calendar_items WHERE expiredate = CURDATE() Link to comment https://forums.phpfreaks.com/topic/114130-only-display-todays-events-from-table/#findComment-586620 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. Link to comment https://forums.phpfreaks.com/topic/114130-only-display-todays-events-from-table/#findComment-586624 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() Link to comment https://forums.phpfreaks.com/topic/114130-only-display-todays-events-from-table/#findComment-586628 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 = '[email protected]'; $mail = new htmlMimeMail(); $mail->setText($message); $mail->setSubject('Faculty/Staff Events'); /** * Sends the message. */ $mail->setFrom($email); $result = $mail->send(array('[email protected]')); //echo $result ? 'Mail sent!' : 'Failed to send mail'; } else { print 'There are no events.'; } ?> Link to comment https://forums.phpfreaks.com/topic/114130-only-display-todays-events-from-table/#findComment-586644 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? Link to comment https://forums.phpfreaks.com/topic/114130-only-display-todays-events-from-table/#findComment-586754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.