i want to give access to only those subject's topics which are alotted to a user i'm taking subject id(sid) when admin upload topics . and by a view file i am trying to match that sid of topic to a from that m-topic table so i stored value og one table in a variale $rs and of secong on $ra and then used if condition in my view file here's my code --
Model code:
public function Select($Table, $Fields = '*', $Where = 1)
{
/*
* Select Fields
*/
if ($Fields != '*') {
$this->db->select($Fields);
}
/*
* IF Found Any Condition
*/
if ($Where != 1) {
$this->db->where($Where);
}
/*
* Select Table
*/
$query = $this->db->get($Table);
/*
* Fetch Records
*/
return $query->result();
}
Controller code:
public function dashboard()
{
$data['rs'] = $this->lib_model->Select('v_subject_faculty_mapping', 'id,Subject,fid,sid', array('fid' => $this->session->EmpId, 'status' => 0 ));
$data['ra'] = $this->lib_model->Select('m_topic', 'id,sid,topic', array('status' => 0 ));
/*
* CK Editor
*/
$path = '../assets/ckfinder';
$width = '85%';
//Loading Library For Ckeditor
$this->load->library('ckeditor');
$this->load->library('ckfinder');
//configure base path of ckeditor folder
$this->ckeditor->basePath = base_url('assets/ckeditor/');
$this->ckeditor->config['toolbar'] = 'Full';
$this->ckeditor->config['language'] = 'en';
$this->ckeditor->config['width'] = $width;
//configure ckfinder with ckeditor config
$this->ckfinder->SetupCKEditor($this->ckeditor, $path);
$this->load->view('f/f_header',$data);
$this->load->view('f/dashboard');
$this->load->view('f/f_footer');
}
View code:
<label>Question Topic</label>
<select class="form-control" required name="S" id="S" style="border: double">
<option selected="">Select Topic</option>
<?php
if ($rs[sid] == $ra[sid]) {
# code...
foreach ($ra as $r)
{
?>
<option value="<?=$r->id;?>"><?=$r->topic;?></option>
<?php
}}
?>
</select>
</div>