Welcome Guest, Not a member yet? Register   Sign In
[Solved] Codeigniter Query Misses First One Off List
#1

(This post was last modified: 12-30-2015, 02:33 AM by wolfgang1983.)

On my query2 foreach loop it produces a list as shown in image that is attached.

But for some reason it keeps on missing the first ones on both list from extra events table

It's missing Test 1 and Example 1


I am not sure why it does not show it on list seems to skip it.

PHP Code:
public function get_events($year$month) {
 
       $calendar = array();

 
       $this->db->select('*');
 
       $this->db->from('events');
 
       $this->db->where('year'$year);
 
       $this->db->where('month'$month);
 
       $query1 $this->db->get();

 
       foreach ($query1->result_array() as $event) {

 
           $this->db->select('*');
         
   $this->db->from('extra_events');
         
   $this->db->where('events_id'$event['events_id']);
         
   $this->db->where('year'$year);
         
   $this->db->where('month'$month);
         
   //$this->db->limit(2);
         
   $query2 $this->db->get();

         
   foreach ($query2->result_array() as $result) {

     
           if (array_key_exists($event['day'], $calendar)) {

     
               // Misses the first one on the list 

             
       $calendar[$event['day']] = $calendar[$event['day']] . '<br/>' $result['extra_event_id'] .' '$result['event'];
             
             
                
} else {

     
               $calendar[$event['day']] = $result['events_id'] .' '$event['event'];

     
           }

 
           }
 
       }

 
       return $calendar;

 
   

Any ideas on how to solve issue?

Attached Files Thumbnail(s)
   
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
[Solved] Codeigniter Query Misses First One Off List - by wolfgang1983 - 12-28-2015, 10:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB