title: php refreshing only data in page
body: <p>i'm a php nearby. I have a problem with my form. I connect the controller with db and extract a question and his three answers. If i click on one of this, the system return the second question, under the first question. If i click on one of the seconds answers, the system return the thirth question overwrite the second question.
  I would like that second question (and its answers) overwrite the first (and its answers). How i can?
  <a href="https://i.stack.imgur.com/0kTzB.png" rel="nofollow noreferrer">db structure</a>
  <a href="https://i.stack.imgur.com/kp6dV.png" rel="nofollow noreferrer">view</a>  </p>
  
  <p>1)  index.php</p>
  
  <pre><code>&lt;?php 
  error_reporting(E_ERROR | E_PARSE);
  require_once 'controllers/controller.php';
  $controllers = new Controller();
  $controllers-&gt;cercaDomanda(1);
  $controllers-&gt;cercaRisposta(1);
  $controllers-&gt;cercaNuovoId($id);
  ?&gt;
  </code></pre>
  
  <p>2) Controller.php</p>
  
  <pre><code>&lt;?php
  require_once('models/Domanda.php');
  require_once('models/Risposta.php');
  require_once ('models/Model.php');
  
  class Controller {
      public $domanda;
      public $risposta;  
      public $model;
  
      public function __construct(){
  
          $this-&gt;domande = new Domanda(); //istanziamo la classe domanda
          $this-&gt;risposte = new Risposta(); //istanziamo la classe risposta
          $this-&gt;model = new Model(); //istanziamo la classe risposta
  
      }
  
      public function cercaDomanda($id){                   
  
          $reslt = $this-&gt;domande-&gt;getDomanda($id);                         
          include 'views/basicView.php';  
          }   
  
       public function cercaRisposta($id){
           $reslt2 = $this-&gt;risposte-&gt;getRisposta($id);
           include 'views/basicView.php';  
          }
  
          public function cercaNuovoId($id){
              include 'views/basicView.php';  
              $reslt3 = $this-&gt;model-&gt;getIdNext();
              $reslt4 = $this-&gt;cercaDomanda($reslt3);
              $reslt5 = $this-&gt;cercaRisposta($reslt3);         
           }   
  } 
  ?&gt;
  </code></pre>
  
  <p>3)Domanda.php</p>
  
  <pre><code>&lt;?php
  require_once 'models/Domanda.php';
  
  class Domanda {
  
      public function getDomanda($id){
          $dbconnection = pg_connect("host=***port=***dbname=***user=***password=***");
          $query = 'SELECT domanda FROM public."Domande" WHERE "id"='.$id;
          $result = pg_query($query); 
          return $result;
          pg_close($dbconnection);
          }
  }
  ?&gt;
  </code></pre>
  
  <p>4)Risposta.php</p>
  
  <pre><code>&lt;?php
  require_once 'models/Risposta.php';
  
  class Risposta {
  
      public function getRisposta($id){
          $dbconnection = pg_connect("host=***port=***dbname=***user=***password=***");
          $query = 'SELECT * FROM public."Risposte" WHERE "id_domanda"='.$id;
          $result = pg_query($query); //or die ('Query fallita: ' .pg_last_error());
          return $result;
          pg_close($dbconnection);
      }    
  }
  ?&gt;
  </code></pre>
  
  <p>5)Model.php</p>
  
  <pre><code>&lt;?php
  require_once 'models/Model.php';
  
  class Model {
  
      public function getIdNext(){
  
          if(isset($_POST['btnScelta'])){      
              $result = $_POST['btnScelta'];
              return $result;         
          }            
      }  
  }
  </code></pre>
  
  <p>6)View</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;&lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;form action='index.php' name='chatbotyForm' method="POST"&gt;
  
  &lt;table&gt;
  
  &lt;?php
  
   echo "&lt;tr&gt;";  
     $domanda = pg_fetch_array($reslt, null, PGSQL_ASSOC);
     print $domanda['domanda'];
     echo "&lt;/tr&gt;";
  ?&gt;
  
  &lt;/table&gt;    
  
  &lt;?php 
         while ($rispost = pg_fetch_object($reslt2)) {
              print "&lt;td&gt;&lt;button type='submit' name='btnScelta'    
              value='$rispost-&gt;id_domanda_successiva'&gt;$rispost-&gt;risposta&lt;/button&gt; 
                &lt;/td&gt;";
               }
  
  ?&gt;
  
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>