title: How can I stay on the same page, when I delete a record?
body: <p>I'm developing a comments system. Right now it is very simple. But I am a bit stuck. </p>
  
  <p>I have a set off rooms that you can book. And for each of the rooms, you can submit comments to them. </p>
  
  <p>When I click my to acess the comments of a room, I sent the room id with the URL, as you can see by the following code:</p>
  
  <pre><code>if (isset ( $_GET ['id'] )) {
      $room_id = $_GET ['id'];
  }
  $user_id = $_SESSION ['id'];
  
  if ($_POST){
          extract($_POST);
          $register = $comment-&gt;createComment($room_id, $user_id, $comments);
  }
  
  ?&gt;
  &lt;div id="comments"&gt;
  &lt;?php  echo  $comment-&gt;getComments($room_id); ?&gt;
  &lt;/div&gt;
  
  &lt;div id="comment-form"&gt;
    &lt;h3&gt;New Comment&lt;/h3&gt;
    &lt;form action="" method="post"&gt;
      &lt;table&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;textarea name="comments" cols="40" rows="8"&gt;&lt;/textarea&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&lt;input type="submit" name="submit" value="Submit Comment" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>To get my comments I call my function <code>getComments($room_id)</code> </p>
  
  <pre><code>public function getComments($room_id) {
  
      $str = "SELECT * FROM comments WHERE room_id = $room_id";
      $result = $this-&gt;db-&gt;mysqli-&gt;query ($str);
      if ($result-&gt;num_rows &gt; 0) {
          $string = "&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;#ID&lt;/th&gt;&lt;th&gt;Room id&lt;/th&gt;&lt;th&gt;user id&lt;/th&gt;&lt;th&gt;comments&lt;/th&gt;&lt;th&gt;Timestamp&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;";
          while ( $row = $result-&gt;fetch_assoc () ) {
              $string .= "&lt;tr&gt;&lt;td&gt;" . $row ['id'] .
              "&lt;/td&gt;&lt;td&gt;" . $row ['room_id'] .
              "&lt;/td&gt;&lt;td&gt;" . $row ['user_id'] .
              "&lt;/td&gt;&lt;td&gt;" . $row ['comments'] .
              "&lt;/td&gt;&lt;td&gt;" . $row ['timestamp'] .
              "&lt;/td&gt;&lt;td&gt;[&lt;a href='deleteComment.php?id=" . $row ['id'] . "'&gt;Delete&lt;/a&gt;]&lt;/td&gt; ";
          }
          $string .= "&lt;/tbody&gt;&lt;/table&gt;";
          return $string;
      }
  }
  </code></pre>
  
  <p>As you can see I create a link that goes to deleteComment.php and sent the link of the comment that I want to delete with it. </p>
  
  <p>On that page I call a new function:</p>
  
  <pre><code>if ($comment-&gt;deleteComment($_GET['id']))
  {
      echo "comment deleted"
  }
  else
  {
      echo "Something went wrong.s";
  }
  </code></pre>
  
  <p>And finally, my delete comment function:</p>
  
  <pre><code>public function deleteComment($id)
      {
          $sql = "DELETE FROM comments WHERE id = ?";
          if (!$result = $this-&gt;db-&gt;mysqli-&gt;prepare($sql))
          {
              return false;
          }
  
          if (!$result-&gt;bind_param('i', $id))
          {
              return false;
          }
  
          return $result-&gt;execute();
      }
  </code></pre>
  
  <p>All of this is working. But <strong>my question is:</strong> How can I delete the comments and still stay on the original page that displays the comments, and not go to the deleteComments.php page? I'm not looking for an AJAX solution. It would be nice if I could just stick to PHP.</p>