Jump to content

only display today's events from table


bradkenyon

Recommended Posts

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

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.'; 
}
?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.