I am creating a module where a students can join a class. Now to do this I need to insert id of the students to get their information.
I have created a query but it only update the table field, so the result is the teacher can only see 1 student in his/her class.
Is there a way to insert multiple ids in one table field to access all students who joined?
Here is my model - so everytime I join a class it updates the field. everytime another user logged in and join class then the value update. So the result is the teacher can only see 1 student and not those who joined in. How can I change this so that students can join in.
public function find_class(){
$data = array(
'student_id' => $this->user_id
);
$this->db->where('code', $this->input->post('code'));
$this->db->like('code', $this->input->post('code'));
return $this->db->update('groups', $data);
}
Controller
public function find_class(){
$this->student_model->find_class();
redirect('students/home');
}
And in my View
<?php echo form_open('students/find_class') ?>
<input type="hidden" value="1" name="studId" />
<div class="form-group">
<h5>Class Code:</h5>
<small><li>Only teachers shall give you code</li></small><br>
<input type="text" class="form-control col-md-6" placeholder="Enter class code to join" name="code" required />
</div>
<hr>
<button type="submit" class="btn btn-info btn-md">Join Class</button>
</form>