如何在php查询中第二次停止相同的数据显示?

i try to development exam management system. I do not want same question or same id not showing second time or other any time exam a user. How can this condition be given?

my function is:

public function qustionShow($question, $limit=4){
    $show = $this->conn->query("select * from question where cat_id ='$question' ORDER BY RAND() LIMIT $limit");
    while ($row=$show->fetch_array(MYSQLI_ASSOC)){
        $this->qus[]=$row;
    }
    return $this->qus;  
}

You would need to keep track of which questions have already been asked. you can save the question id's to the Session if it's you don't want the questions to be selected again only for the session.

you could initialize an array to the session $_SESSION['questions_asked'] = array(); and then once a question is asked you would

array_push([THE QUESTION ID], $_SESSION['questions_asked']);

of course you need to replace [THE QUESTION ID] with the sql id for whatever question was asked

keep in mind you would need to modify your query to account for anything saved in the session.

If you don't want them to ever be shown again you would need to record which questions a user has seen and would need to store that persistently in the database probably.

possibly you can have a table to store those in for each user

user_question_asked

with at least these 2 columns

[user_id][question_id]

so each time a question is asked you insert the current user id and question id

then your query could be

SELECT * FROM question where cat_id ='$question' AND [QUESTION_ID] NOT IN 
(SELECT question_id from  user_question_asked where user_id [CURRENT USER's ID] 
) ORDER BY RAND() LIMIT $limit;`

Hope that helps, I'm not sure what your table / column structure is, but those are a couple suggestions I have for addressing this problem.