DEV Community

Display records from Database one at a time

JeevaSaravanan on December 08, 2019

Can anyone tell me how to retrieve records from database one at a time. I am attaching my code here: Let me explain the code.. The database I am...
Collapse
 
njungejnr profile image
ChangeIsMe

I will try to answer your question based on what I have understood.

  1. SELECT * FROM cquest ORDER BY yourprimkey DESC LIMIT 1
    -This will return only one record, am not sure whether they have a systematic order, in such a case, just change your 'ORDER BY...*' but retain the LIMIT 1.

  2. When a user clicks next to go to next question, you can pass a parameter . of question id and increment by one, ie yourprimkeyid+1 or yourprimkey -1 to get the next question then just do
    SELECT * FROM cquest where yourprimkeyid = yourprimkeyid+1

I hope thats answers your question.