Jump to content

Field in query missed out but all other work


fife
Go to solution Solved by fife,

Recommended Posts

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