[eluser]bianchi[/eluser]
Hello friends,
I wanna delete multiple records using checkbox...
I always get
Call to a member function delete() on a non-object in C:\Program Files\xampp\htdocs\fids_2\module\application\controllers\checkbox.php on line 27
==============
Any helps / suggestions will be appreciated..
Thx..
==================
The controller :
<?
class Checkbox extends Controller{
function Checkbox(){
parent::Controller();
$this->load->helper('url');
$this->load->database();
}
function index(){
//$this->load->library('table');
//load pagination class
//$this->load->library('pagination');
//$this->load->helper('html');
$this->load->model('checkboxModel');
//load model and ambil hasilnya
$data['query'] = $this->checkboxModel->checkbox_getall();
$this->load->view('checkbox_view',$data);
}
function delete(){
$dat=$this->input->post('airline');
for($i=0; $i<sizeof($dat);$i++)
{
$this->checkboxModel->delete($dat[$i]);
}
//$this->load->view('checkbox_view3',$data);
}
}
?>
The model :
<?php
class checkboxModel extends Model
{
function checkbox_getall()
{
$this->load->database();
$this->db->order_by('name','asc');
$this->db->limit(10);
$query = $this->db->get('ins_code_airlines');
return $query->result();
}
function delete($code2)
{
//$this->db->where('code2', $code2);
//$this->db->delete('ins_code_airlines');
$this->db->query("DELETE FROM 'ins_code_airlines' WHERE `code2` = '$code2' ");
}
}
?>
the view :
<html>
<head>
[removed]
<!--
<!-- Begin
function CheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}
function UnCheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
// End -->
[removed]
</head>
<body>
<br>
<form name="airline_form" action="checkbox/delete" method="post">
<input type="button" name="Check_All" value="Check All">
<input type="button" name="Un_CheckAll" value="Uncheck All">
<input type="submit" value="DELETE" class="button"/>
<br>
<? //foreach($query as $row){ echo "<option value='$row->code2'>$row->name</option>";}
foreach($query as $row){ echo "<input type='checkbox' name='airline1' value='$row->code2'>$row->name<br>";}?>
<input type="submit" value="DELETE" class="button"/>
</form>
</body>
</html>