fife Posted July 30, 2013 Share Posted July 30, 2013 I have a query which is looking for events on any given month of the year. It looks as follows... $events = array();mysql_select_db($database_dbconnect, $dbconnect);$query = "SELECT calsect, title,idcalendar, DATE_FORMAT(event_date,'%Y-%m-%d') AS event_date FROM calendar WHERE event_date LIKE '$year-$month%'";$result = mysql_query($query, $dbconnect) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) {$events[$row['event_date']][] = $row;} I then have a function which calls a calendar. As the function is looping through days of the week it also checks on each day if there is any event. If there is it prints it. If not it moves on to the next day. It actually works great. I can echo the title, idcalendar and the event_date but I can not the calsect field. /* print "blank" days until the first of the current week */for($x = 0; $x < $running_day; $x++):$calendar.= '<td class="calendar-day-np"> </td>';$days_in_this_week++;endfor; /* keep going with days.... */for($list_day = 1; $list_day <= $days_in_month; $list_day++):$calendar.= '<td class="calendar-day"><div style="position:relative;height:100px;">';/* add in the day number */$calendar.= '<div class="day-number">'.$list_day.'</div>'; $event_day = sprintf('%04d-%02d-%02d', $year, $month, $list_day); /* list the events */if(isset($events[$event_day])) {foreach($events[$event_day] as $event) { //My title appears but the $event['calsect'] is not!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $calendar.='<div class="' .$event['calsect']. '">' .$event['title']. '</div>';}}else {$calendar.= str_repeat('<p> </p>',2);} If I view source on an event I get this. <div class="">Test Event</div> where class should equal $event['calsect'] (or blue in this case) . Link to comment https://forums.phpfreaks.com/topic/280643-field-in-query-missed-out-but-all-other-work/ Share on other sites More sharing options...
mac_gyver Posted July 30, 2013 Share Posted July 30, 2013 is calsect the exact spelling and capitalization of your database column name? Link to comment https://forums.phpfreaks.com/topic/280643-field-in-query-missed-out-but-all-other-work/#findComment-1442677 Share on other sites More sharing options...
fife Posted July 30, 2013 Author Share Posted July 30, 2013 yes calsect all lower case. Am I somehow not including it in the loop? Link to comment https://forums.phpfreaks.com/topic/280643-field-in-query-missed-out-but-all-other-work/#findComment-1442687 Share on other sites More sharing options...
fife Posted July 30, 2013 Author Share Posted July 30, 2013 OK guys simple lesson for everyone. Don't declare your query twice in your scripts. One over rides the other. Ops. Sorry for wasting anyone's time. Link to comment https://forums.phpfreaks.com/topic/280643-field-in-query-missed-out-but-all-other-work/#findComment-1442699 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.