dimanche 29 novembre 2015

Codeigniter random and filtered

i want a result filtered by id and number of rcount.

this is my objectives table

http://ift.tt/1Iihi4F

objective_question table

http://ift.tt/1loqv0X

i already have this query with codeigniter

$this->db->select("objectives.id, objectives.rcount, objective_questions.question, objective_questions.a, objective_questions.b, 
                 objective_questions.c, objective_questions.d, objective_questions.answer");

$this->db->from("objectives");

$this->db->join("objective_questions", "objectives.id = objective_questions.objective_id");

$this->db->where("sub_module_id", $sub_module_id);

$query = $this->db->get();

with this result of

http://ift.tt/1Iihj8G

what i want is to query the sub_module_id and pick a random question by the number of rcount where objectives.id is equal to objective_questions.objective_id, so total of question will i get based on my two tables is 9. 1 + 4 + 4 = 9.

any idea how do i get the result? Thank you.!




Aucun commentaire:

Enregistrer un commentaire