Jump to content

Classtime Table Help


imperium2335

Recommended Posts

Hi,

 

I have a page on my site where it shows classes taking place this month, next month, and the month after.

 

The problem is, is that I have classes appearing a month earlier than they should be, here is my code:

<?PHP

include("dbconnect.php") ;

for($i=0;$i<3;$i++) {
$x = $i+1 ;
$result = $dbh->prepare("SELECT id, className, classDate
					   FROM classes
					   WHERE classDate < DATE_ADD(NOW(), INTERVAL ? MONTH)
					   AND (classDate > DATE_ADD(NOW(), INTERVAL ? MONTH) OR ? = 0)
					   AND classDate > DATE_SUB(NOW(), INTERVAL 1 DAY)
					   ORDER BY classDate ASC") ;
	$result->bindParam(1, $x, PDO::PARAM_INT) ;
	$result->bindParam(2, $i, PDO::PARAM_INT) ;
	$result->bindParam(3, $i, PDO::PARAM_INT) ;
$result->execute() ;

echo '<div class="classColumn">' ;
if($i > 0)
	echo '<span class="cTitle">' . $month = date('F', strtotime(date("M", time()) . " +$i month")) . '</span>' ;
else
	echo '<span class="cTitle">This month</span>' ;
while($row = $result->fetch()) {

	echo '<div class="classBlock">' ;

	echo '<img src="' . 'cake-classes-logo.jpg" alt="' . '" width="64" height="64"/>' ;

	echo '<span class="classTitle">' . $row['className'] . '</span><br />' ;

	echo "</div>" ;

}
echo '</div>' ;

}

?>

 

I don't know if it is just the date titles not syncing up with the results i.e. the

echo '<span class="cTitle">' . $month = date('F', strtotime(date("M", time()) . " +$i month")) . '</span>' ;

bit.

 

Link to comment
https://forums.phpfreaks.com/topic/253939-classtime-table-help/
Share on other sites

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.