Closed zishan0215 closed 9 years ago
public function view_teacher() { $this->data['page'] = 1; $this->data['name'] = $this->session->userdata('name'); $this->data['teacher_id'] = $this->input->post('teacher_id'); $array = array('teacher_id' => $this->data['teacher_id']); $this->data['teacher1']=$this->teacher_m->get_by($array,TRUE); $this->data['teacher2']=$this->subject_m->get_by($array); $this->data['subject_code'] = $this->input->post('subject_code'); $array=array("subject_code"=>$this->data['subject_code'],"teacher_id"=>0); $this->teacher_m->save($array); $this->load->view('admin/components/admin_header', $this->data); $this->load->view('admin/view_teacher_layout'); }
$array=array("subject_code"=>$this->data['subject_code'],"teacher_id"=>0); $this->teacher_m->save($array); // To insert new data OR $this->teacher_m->save($array, $id); //To update existing data with given id
yahi to kiya hai maine
public function view_teacher() { $this->data['page'] = 1; $this->data['name'] = $this->session->userdata('name'); $this->data['teacher_id'] = $this->input->post('teacher_id'); $array = array('teacher_id' => $this->data['teacher_id']); $this->data['teacher1']=$this->teacher_m->get_by($array,TRUE); $this->data['teacher2']=$this->subject_m->get_by($array); $this->data['subject_code'] = $this->input->post('subject_code'); $array=array("subject_code"=>$this->data['subject_code'],"teacher_id"=>0); $this->teacher_m->save($array); $this->load->view('admin/components/admin_header', $this->data); $this->load->view('admin/view_teacher_layout'); }
kya kar rahe ho ?
This is not the way to do it..
tumne bhi to same cheez likhi hai upar
$array=array("subject_code"=>$this->data['subject_code'],"teacher_id"=>0); $this->teacher_m->save($array);
firstly.. this query should only run when the admin clicks on the remove button.. secondly, what you are doing is insertion and not updation
so how to check if remove is clicked or not?
refer increment semester
ok
using  ??
its just for space
$this->data['subject_code'] = $this->input->post('subject_code'); if($this->data['subject_code']){ $array=array('subject_code'=>$this->data['subject_code'],'teacher_id'=>0); $this->subject_m->save($array,$this->data['teacher_id']); }
ab theek hai??
nope...if condition is wrong
kya galat hai isme?
$array=array('teacher_id' => 0);
just use this
foreign key constraint hai
if condition galat hai tumhari.. pehle usko theek karo
pehle yeh batao ki subject table mein hum teacher_id=0 kaise kr sakte hain jab ki koi teacher ki teacher_id 0 nhi hai
delete hi krna padega
hai teacher id 0.. check the database
mere mein nhi hai
lol
aagaye??
haan
kaam ho gya
but ek error hai
kya
delete ho ja rhi hain
kya
wait main screen shot bhejta hoon
public function view_teacher() { $this->data['page'] = 1; $this->data['name'] = $this->session->userdata('name'); $this->data['teacher_id'] = $this->input->post('teacher_id'); $array = array('teacher_id' => $this->data['teacher_id']); $this->data['teacher1']=$this->teacher_m->get_by($array,TRUE); $this->data['teacher2']=$this->subject_m->get_by($array); $this->data['subject_code'] = $this->input->post('subject_code'); if(isset($_POST['subject_code'])){ $array=array('teacher_id'=>0); $this->subject_m->save($array,$this->data['subject_code']); } $this->load->view('admin/components/admin_header', $this->data); $this->load->view('admin/view_teacher_layout'); }
nowcheck
abhi bhi galat hai if condition
kya galata hai
maine net se dekhi hai
net se kyun dekh rahe ho.. code nahi dekh sakte ? keh raha hun increment waale main dekho kaise pata chal raha hai kab click kiya button ko
vo samajh nhi aaraha
if($this->input->post('submit')) { //code here }
bhai tum ajeeb ho
upar wala bhi same chhez krta hai
no
uss button ka naam remove hai
not submit
and uska name hai subject_code
karlo changes.. idea de raha hun tumhe
So lets discuss this here