how to randomize retrieval of question from database?

后端 未结 5 1453
南旧
南旧 2021-01-20 15:06

.i have the following code:



        
5条回答
  •  北海茫月
    2021-01-20 15:24

    A potential approach would be:

    1. Fetch the question IDs from the database when you detect a new user/on the 1st question via ORDER BY RAND() LIMIT 5 in SQL.

    2. Store these in the $_SESSION.

    3. Iterate through the question IDs in the $_SESSION, loading the full question data from the DB via the ID.

提交回复
热议问题