Welcome Guest, Not a member yet? Register   Sign In
Set Post active by current date
#13

[eluser]Zimooon[/eluser]
Hey to get you on my current stand :
My end is atm int(20).
my modelcode is
Code:
function getactiveCalender($active = TRUE) {
      
      
    if($active == FALSE)
    {
     $this->db->where('active',0);
    }
  
    $query = $this->db->get('calender');
    $calender = array();

    foreach ($query->result() as $row) {
//-->
        if($row->end < now){ // Wenn das Enddatum schon vorbei ist
            $row->active = FALSE;   // aktiv auf FALSE setzen
        } // end if row->end < now
//--&gt;
        $calender[] = array(
            'id' => $row->id,
            'ctitle' => $row->ctitle,
            'ccontent' => $row->ccontent,
            'start' => $row->start,
            'end' => $row->end,
            'active' => $row->active
        );
    
          
    }

        
    return $calender;      

}

This is my create_calender controller:
Code:
function create_calender()
  {
      // Check if form is submitted
    if (!$this->ion_auth->logged_in())
    {
            //redirect them to the login page
            redirect('auth/login', 'refresh');
        }

        else
        {
    
        if ($this->input->post('submit')) {
            
            $ctitle = $this->security->xss_clean($this->input->post('ctitle'));
            $ccontent = $this->security->xss_clean($this->input->post('ccontent'));
            $start = $this->security->xss_clean($this->input->post('start'));
            $end = $this->security->xss_clean($this->input->post('end'));
            $active = $this->security->xss_clean($this->input->post('active'));
    
            
            // Add the post
            $this->Calender_model->addCalender($ctitle,$ccontent,$start,$end,$active);
        }

        $data = array();


        $data['calender'] = $this->Calender_model->getCalender();
        $this->load->view('auth/create_calender', $data);
        $this->data['title'] = "Kalender erstellen";
    
    }
  }

Maybe it is a problem to set the entries active/inactive manuall at start?

ATM all my entries are displayed. But all are set active = 1 in my database so it seems to be normal.

How would you set the end? int(20) is ok?
Whats wrong with the model code that it don't write active to 0 when the time expired?
best regards


Messages In This Thread
Set Post active by current date - by El Forum - 04-26-2011, 02:43 AM
Set Post active by current date - by El Forum - 04-26-2011, 03:17 AM
Set Post active by current date - by El Forum - 04-26-2011, 03:44 AM
Set Post active by current date - by El Forum - 04-26-2011, 03:55 PM
Set Post active by current date - by El Forum - 04-27-2011, 03:32 AM
Set Post active by current date - by El Forum - 04-27-2011, 04:48 AM
Set Post active by current date - by El Forum - 04-27-2011, 06:43 AM
Set Post active by current date - by El Forum - 04-27-2011, 06:55 AM
Set Post active by current date - by El Forum - 04-27-2011, 07:47 AM
Set Post active by current date - by El Forum - 04-27-2011, 10:14 AM
Set Post active by current date - by El Forum - 04-27-2011, 10:28 AM
Set Post active by current date - by El Forum - 04-28-2011, 01:14 AM
Set Post active by current date - by El Forum - 04-28-2011, 01:30 AM
Set Post active by current date - by El Forum - 04-28-2011, 07:47 AM
Set Post active by current date - by El Forum - 04-28-2011, 09:16 AM
Set Post active by current date - by El Forum - 04-28-2011, 09:25 AM
Set Post active by current date - by El Forum - 04-28-2011, 12:13 PM
Set Post active by current date - by El Forum - 04-29-2011, 02:16 AM
Set Post active by current date - by El Forum - 04-29-2011, 12:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB