Welcome Guest, Not a member yet? Register   Sign In
problem to edit form
#1

[eluser]Unknown[/eluser]
hi everyone,
i am new in codeigniter. i've try to edit my form but it's not working during click edit link. can everyone see my code which part has a error..
my controller(books.php)
<?php
class Books extends CI_Controller{

public $data = "";
//parent construct
function __construct(){
parent:: __construct();

$this->load->model('books_model');//load only one in construct
$this->load->library('table');//load table
$this->load->helper('html');//load html
$this->load->helper('form');//load form
}

function main(){

$data=$this->books_model->general();//load general method

$data['query']=$this->books_model->get_update();//declare method query #array#
$data['table']=$this->books_model->get_update();//load get_update method-->table#array#

$this->load->view('kiosk/blog/books_main',$data);//display data
}
//update input
function input($id=0){

if($this->input->post('mysubmit'))
{
$this->books_model->insert_data();
}

if($id>0){

//declare fieldname data for #id# n display array *id*
$data['fid']['value']=$query['id'];
$data['ftitle']['value']=$query['title'];
$data['fauthor']['value']=$query['author'];
$data['fpublisher']['value']=$query['publisher'];
$data['fyear']['value']=$query['year'];

if($query('available') == 'yes'){
$data['favailable']['checked'] = TRUE;
}else{
$data['favailable']['checked'] = FALSE;
}
$data['fsummary']['value']=$query['summary'];

$query=$this->books_model->get_edit($id);
$data['query']=$this->books_model->get_edit();
}

function delete($id)
{
if($id>0){
$this->books_model->get_delete($id);
}
$data = $this->books_model->general();
$data['query'] = $this->books_model->get_update();
$this->load->view('kiosk/blog/books_main',$data);
}

$this->load->helper('form');//load helper for form
$this->load->helper('html'); //load html
$data=$this->books_model->general();//call data->from model->where function to display##
$this->load->view('kiosk/blog/books_input',$data);//load to view that page

}

}

?>

---this is my model(books_model.php)---

<?php

class Books_model extends CI_Model{

function __construct() {
parent::__construct();

$this->load->helper('url');
$this->load->database();
$this->load->library('table');
}

//add function insert_data into table#insert#
function insert_data(){
$data=array(
'title' =>$this->input->post('ftitle'),
'author' =>$this->input->post('fauthor'),
'publisher'=>$this->input->post('fpublisher'),
'year' =>$this->input->post('fyear'),
'available'=>$this->input->post('favailable'),
'summary' =>$this->input->post('fsummary')//#db name#-#fieldname#
);
$this->db->insert('books',$data);

}

//add function get_data()||get_all() from db #update#
function get_update(){
$query=$this->db->query(' SELECT * FROM books ');//select all table query
return $query;//query array of object
}

//add function for edit
function get_edit($id){
$query=$this->db->get_where('books',array('id'=>$id))->row();//#table_name##array_id#
return $query;//->row_array();
}

function general(){
$this->load->library('Books_helper');
$menu = new Books_helper;
$data['menu']=$menu->show_menu();//call from library
$data['title']='Book Collection';
$data['subtitle']='All data collected around the world';
$data['footer']='© All Reserved to Kourux87';
//add new data#array##declare_data#
$data['title']='Title';
$data['author']='Author';
$data['publisher']='Publisher';
$data['year']='Year';
$data['years']=array(
'' => 'Please Select',
'1'=>'2000-2004',
'2'=>'2005-2009',
'3'=>'2010-2013'
);//array for dropdown data (2)
$data['available']='Available';
$data['summary']='Summary';
$data['forminput']='Form Input';

//insert data (3)
$data['ftitle']=array(
'name'=>'title',
'size'=>30
);
$data['fauthor']=array(
'name'=>'author',
'size'=>30
);
$data['fpublisher']=array(
'name'=>'publisher',
'size'=>30
);
$data['favailable']=array(
'name'=>'available',
'value'=>'yes',
'checked'=>TRUE
);
$data['fsummary']=array(
'name'=>'summary',
'cols'=>30,
'rows'=>5
);

return $data;
}
}
?>

Please help me. Thank you..

#2

[eluser]InsiteFX[/eluser]
If you want users on the forum to help you please wrp your code in code tags or it will not get read and answered.




Theme © iAndrew 2016 - Forum software by © MyBB