error by getting events from database. |
[eluser]shinokada[/eluser]
The following code give errors in CI. If I use it in normal php, it does not give any. Could anyone point out what I need to correct? Thanks in advance. Code: $query = $this->db->query("SELECT DATE_FORMAT(eventDate,'%d') AS day,eventContent,eventTitle FROM eventcal WHERE eventDate BETWEEN '$current_year/$current_month/01' AND '$current_year/$current_month/$total_days_of_current_month'"); Quote:Severity: Notice Line Number 32 is this part. Code: $events[intval($row_event->day)] .= '<li><span class="title">'.stripslashes($row_event->eventTitle).'</span><span class="desc">'.stripslashes($row_event->eventContent).'</span></li>'; Whole code of model is here. Code: function getEvents(){ Original code is from here.http://iambari.com/2009/05/05/create-an-...nd-jquery/
[eluser]JHackamack[/eluser]
I believe this is because you're telling PHP to add to an existing value of $events[intval($row_event->day)], but if you're calling a day that didn't have any events yet you're trying to add to something that doesn't exist. If it works the way you want you can turn of error reporting so the notice doesn't appear, but thats not very PHP like. The best way would be to use the following code: $events[intval($row_event->day)][] = Then in your view you use foreach $events[$day] as $event rather than just echoing a string. |
Welcome Guest, Not a member yet? Register Sign In |