CodeIgniter Forums
passing query result into calendar class? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: passing query result into calendar class? (/showthread.php?tid=6211)



passing query result into calendar class? - El Forum - 02-18-2008

[eluser]jigen7[/eluser]
Hi everyone I cant seem to make this work, i got a function in the model where it returns the date of the query then store the sql result to an array $date_arr then pass that variable to the calendar just lyk in the User Guide but when i tried it,
the calendar only display the last query result of the date??can anyone help me here??thx

Model Code
Code:
function get_calendar_date($id,$month,$year){

     $sql = "Select Date FROM schedule WHERE resort_id = $id AND Month = $month AND Year = $year";
     $query = $this->db->query($sql);
    
     return $query;
    
    
    }

Controller Code
Code:
$query = $this->Reservations->get_calendar_date($id,$month,$year);
    
        $date_arr = array();
        foreach($query->result() as $row):
        $date_arr[$row->Date] =  $row->Date;
        endforeach;
        print_r($date_arr);
        $data['cal'] = $this->calendar->generate($year,$month,$date_arr);
        $this->load->view('calendar',$data);



passing query result into calendar class? - El Forum - 02-19-2008

[eluser]jigen7[/eluser]
can anyone help me here?still havent find a way


passing query result into calendar class? - El Forum - 02-19-2008

[eluser]Pygon[/eluser]
Nevermind...


passing query result into calendar class? - El Forum - 02-19-2008

[eluser]jigen7[/eluser]
yes its working its returning the result but the calendar only shows the last result not all.


passing query result into calendar class? - El Forum - 02-19-2008

[eluser]Pygon[/eluser]
What is the output of your print_r($date_arr);


passing query result into calendar class? - El Forum - 02-19-2008

[eluser]jigen7[/eluser]
heres the print_r

Array ( [28] => 28 [05] => 05 [26] => 26 )


passing query result into calendar class? - El Forum - 02-19-2008

[eluser]jigen7[/eluser]
yey i got it now the calendar cant display the date with 0 at front so i need to truncate the 0 at 05 for it to display ^_^ thx for helping