title: i wanted to use next and previous button for fetching data from database using php
body: <p>I am making a exam portal in which i have option conducting exam/quiz. Now i have added 2 buttons namely Next and Previous . I wanted to fetch Question and its option on button Click.
  My database has following structure: Question(qid,question,option1,option2,option3,option4,right_option)
  What I am tryin to do: </p>
  
  <pre><code>&lt;input id="first" type="button" value="NEXT" onClick = "show_next()"&gt;
  &lt;input id="second" type="button" value="PREV" onClick = "show_prev()"&gt;
  
  &lt;script&gt;
  function show_next()
  {
  &lt;?php 
  $question_no; //my global php variable to keep track of question id
  $question_no = $question_no + 1; 
  show_question($question_no); //php function which shows data according to question no 
  ?&gt;
   }
  function show_prev()
  {
  &lt;?php 
  if($question_no&gt;0)
  {
  $question_no = $question_no-1;
  show_question();
  }
  else
  {
  ?&gt;
  alert("Wrong Operation");
  &lt;?php
  }
  ?&gt;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I am new to php and javascript, please suggest the correct method and if possible coding snippet for my question</p>