imperium2335 Posted December 28, 2011 Share Posted December 28, 2011 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 More sharing options...
fenway Posted December 29, 2011 Share Posted December 29, 2011 I can't guess what that query is going to do. Link to comment https://forums.phpfreaks.com/topic/253939-classtime-table-help/#findComment-1302196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.