I created a page (exam.php) where I want to show questions one by one.

When a student clicks next after submitting an answer I want it to display the next question.

```
 <?php
    if(!isset($_SESSION['qno']))
        $_SESSION['qno'] = 1;
    else{

        if(isset($_POST['next']))
        {
                $_SESSION['qno'] += 1;
        }

    }

    $sql ="select  * from question where question_id= ' ".$_SESSION['qno']." '  ";
    $query=mysql_query($sql);
    while($row = mysql_fetch_assoc($query))
    {
        $question =$row['question'];
        $op1 = $row['option1'];
        $op2 = $row['option2'];
        $op3 = $row['option3'];
        $op4 = $row['option4'];

    }

    ?>

```

It works, but in this code I am using question\_id to display data. The problem comes after, when admin deletes some questions it is not working due to question\_id gap.

I initialize question\_id =1; so what is best solution for this problem?