function temp(){
$id = $this->input->post('id');
$rub = $this->input->post('rub');
$cont = $this->input->post('cont');
$err = "Inget gjordes du är nog utloggad!";
if($rub !="" and $cont != ""){
$a = array('rub' => $rub,
'cont' => $cont,
'userid' => $this->session->userdata('id') );
$this->db1->insert('pro_user_mailer', $a);
$err = "All good, posten uppdaterades";
} else {
$err = "Fälten verkar vara tomma!";
}
echo json_encode(array('err' => $err, 'post' => $a ));
}
Basic query’s in Codeigniter
Loop
// Loop
$q = $this->db->get_where("", array('' => ''));
if ($q->num_rows() > 0) {
foreach ($q->result() as $r){
echo $r->id;
}
}
// Row
$q = $this->db->get_where("", array('' => ''));
if ($q->num_rows() > 0){
$r = $q->row();
echo $r->id;
}
//query
$q = $this->db->query("");
if ($q->num_rows() > 0){
$r = $q->row();
echo $r->id;
}