I have a jquery calendar in my cakephp application with <?php //foreach ($mealplans as $mealplan){ ?> { title: '<?php echo $mealplan['Mealplan']['event_name'] . ", ". $mealplan['Mealplan']['total_calories']. " cals"; ?>', start: new Date(y, m, <?php $event = $mealplan['Mealplan']['event_date']; echo substr($event, 0, -8); ?>, 0), end: new Date(y, m, 16), allDay: true, url: 'http://localhost/mealplans/view/1' }, <?php //} ?> Code (markup): When I uncomment foreach and its curly bracket at the end then it prints out the first of my meal plans on January 15 until January 16 but I want it to print out all of them. Most of the php is working in the jquery code it's just this one part that doesn't work. When I uncomment the foreach and its end bracket then the calendar disappears. You can see it at http://myownmealplanner.com/calendars/navigate The calendar code is from http://arshaw.com/fullcalendar/docs/usage/
I found the problem. One of the meal plans had no date associated with it and the jquery was corrupted as a result. It works now at localhost.
You have one other glaring train wreck (that most people are guilty of) - open PHP, write your code and close PHP. ONCE. Stop opening and closing it all over the place. <?php foreach ($mealplans as $mealplan){ echo 'title: '.$mealplan['Mealplan']['event_name'] . ", ". $mealplan['Mealplan']['total_calories']. " cals,"; echo 'start: new Date(y, m, '; $event = $mealplan['Mealplan']['event_date']; echo substr($event, 0, -8).', 0),'; echo 'end: new Date(y, m, 16),'; echo 'allDay: true,'; echo 'url: "http://localhost/mealplans/view/1"'; } ?> //assuming this is the end of the file PHP: I may have caused a typo or two, but you get the idea.