Welcome Guest, Not a member yet? Register   Sign In
Fill calendar events with database, dont show events with day less than 10 [SOLVED]
#1

[eluser]Asinox[/eluser]
Hi, im try to fill the calendar with events from database, the calendar is "fine", is working, but just with day not less than 10, for example, if i have events in this date (2009-03-25) the calendar is fine, excellent , but if the events are in date like (2009-03-01) don't show link's in the months....just when the day is not less than 10

Sad



how ill fix that guys?

Thanks

PD: i was looking that post http://ellislab.com/forums/viewthread/106361/ and i try to make in my way

my code
Code:
$this_month_events = array();
$next_month_events = array();


foreach($eventos as $row){
    $fecha = explode('-',$row->fecha); //from data base field fecha 2009-03-25
    $ano = $fecha[0];
    $mes = $fecha[1];
    $dia = $fecha[2];
    
    if($ano==$this->uri->segment(3) && $mes == $this->uri->segment(4)){
            $this_month_events[$dia] = base_url().'index.php/calendario/'.$ano.'/'.$mes.'/';        
    }else if($ano == $next_months_year && $mes == $this->uri->segment(4)){
            $next_month_events[$dia] = base_url().'index.php/calendario/'.$ano.'/'.$mes.'/';
    }
}

echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4), $this_month_events);

Thanks for see
#2

[eluser]sophistry[/eluser]
un consejo...
print_r($fecha);
it sounds like something is going wrong with explode().
#3

[eluser]Asinox[/eluser]
thanks for replay.

not the explode is fine

the problem is that if the date from database is something like 2009-10-04, the day have a 0 and this is the problem, the example in the user_guide is without 0 if the number is less than 10.
Code:
$this->load->library('calendar');

$data = array(
               3  => 'http://example.com/news/article/2006/03/',
               7  => 'http://example.com/news/article/2006/07/',
               13 => 'http://example.com/news/article/2006/13/',
               26 => 'http://example.com/news/article/2006/26/'
             );

echo $this->calendar->generate(2006, 6, $data);

in the example the day 3 and 7 are without 0, so i think the problem is there.

thanks

Sorry with my English.
#4

[eluser]sophistry[/eluser]
key has to be integer.
#5

[eluser]Asinox[/eluser]
yes, sure!, like a said, the calendar working in "day" that don't start with 0.and my day start with 0 bcz mysql in type DATE insert in the format YYYY-mm-dd, if a send a 2009-12-3 mysql add a 0 in the day "3" bcz the DATE FORMAT is YYYY-mm-dd. but any way im making a function for delete the 0.

Thanks
#6

[eluser]Asinox[/eluser]
now my calendar is fine Big Grin working with data from database Big Grin

CODE HERE: if someone need it

Code:
$days_in_month = date('t'); //ie 28
$todays_date = date('j'); //17
$this_month = date('n'); //2
$next_month = date('n', strtotime('next month')); //3
$this_months_year = date('Y'); //2009
$next_months_year = date('Y', strtotime('next month')); //2009 (if this month is Dec, this will be 2010)

$this_month_events = array();
$next_month_events = array();

foreach($eventos as $row){
//    print_r($row->fecha);
    $fecha = explode('-',$row->fecha);
    $ano = $fecha[0];
    $mes = $fecha[1];
    $dia = $fecha[2];
    
    

    $dia_sin_cero = ltrim($dia, "0");
    
    if($ano==$this->uri->segment(3) && $mes == $this->uri->segment(4)){
            $this_month_events[$dia_sin_cero] = base_url().'index.php/calendario/'.$ano.'/'.$mes.'/';        
    }else if($ano == $next_months_year && $mes == $this->uri->segment(4)){
            $next_month_events[$dia_sin_cero] = base_url().'index.php/calendario/'.$ano.'/'.$mes.'/';
  }
    
}

echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4), $this_month_events);




Theme © iAndrew 2016 - Forum software by © MyBB