[ad_1]
I am trying to save dates(start and end date) from datepicker and description of the event.
My Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Calendar extends CI_Controller
{
public function __construct() {
Parent::__construct();
$this->load->model("calendar_model");
}
public function index()
{
$this->load->view("user/calendar.php", array());
}
public function add_event()
{
/* Our calendar data */
$sched_desc = $this->input->post("sched_desc", TRUE);
$start = $this->input->post("start", TRUE);
$end = $this->input->post("end", TRUE);
$this->calendar_model->add_event(array(
"sched_desc" => $sched_desc,
"start" => $start,
"end" => $end
)
);
redirect(site_url("calendar"));
}
}
?>
My Model
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Calendar_model extends CI_Model {
/*Create new events */
Public function addEvent()
{
$sql = "INSERT INTO events (title,events.start,events.end,description, color) VALUES (?,?,?,?,?)";
$this->db->query($sql, array($_POST['title'], $_POST['start'],$_POST['end'], $_POST['description'], $_POST['color']));
return ($this->db->affected_rows()!=1)?false:true;
}
}
?>
I wanted to create a schedule setter wherein admin can set schedule to a specific event and should have start date and end date and also description of the event.
[ad_2]