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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.