mardi 31 juillet 2018

I'm not getting the right random value. There are 6 values in my database. I give Limit 3. But the first 4 items shows randomized

I need 3 question from 6. but every time randomize show fast 4 question.

    /*for random question*/
public function qustionShow($question){

    $query = $this->conn->query("select * from question where cat_id='$question'");
    $c = mysqli_num_rows($query);
    $rand = rand(3, $c)-3;


    $show = $this->conn->query("select * from question where cat_id ='$question' and id >'$rand' LIMIT 4");
    while ($row=$show->fetch_array(MYSQLI_ASSOC)){
        $this->qus[]=$row;
    }
    return $this->qus;  
}




Aucun commentaire:

Enregistrer un commentaire