title: Carry over specific data from mysql query result when user selects data
body: <p>This is my first ever question on stackover flow so hope i explain it well. I am fairly new to php/js/html and i have run into a problem. I query my database using a session variable and it returns all the results that are associated with the logged in user. 
  Below is the php code i used to get the results.</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  include('conn.php');
  
  if(!isset($_SESSION['40219357_user'])){
      header('Location:index.php');
  }
  
      $username = $_SESSION['40219357_user'];
      $userid = $_SESSION['40219357_id'];
  
      $read = "SELECT * FROM medi_users WHERE dr_id = '$userid'";
      $result = $conn -&gt;query($read);
  
  ?&gt;
  </code></pre>
  
  <p>The result of this query is displayed in a table on my website. When the logged in user of the website clicks on a person's record it should show all the information relating to that specific person.</p>
  
  <p>Since asking my original question i have found a simple solution to my problem by passing the user id as a hidden value in a button. The code for this is below.</p>
  
  <pre><code>&lt;?php
  
          while($row = $result -&gt;fetch_assoc()){
              $rowid = $row['id'];
              $firstname = $row['firstname'];
              $surname = $row ['surname'];
              $dob = $row['dob'];
              $address = $row['address'];
              $town = $row['town'];
              $postcode = $row['postcode'];
  
  
              echo"   
                  &lt;tbody&gt;
                      &lt;tr&gt;
                          &lt;td&gt;$firstname&lt;/td&gt;
                          &lt;td&gt;$surname &lt;/td&gt;
                          &lt;td&gt;$dob&lt;/td&gt;
                          &lt;td&gt;$address&lt;/td&gt;
                          &lt;td&gt;$town&lt;/td&gt;
                          &lt;td&gt;$postcode&lt;/td&gt;
                          &lt;td&gt;&lt;a class = 'btn btn-danger' 
                   href `='patientsmedication.php?editid=$rowid'&gt;View&lt;/a&gt;&lt;/td&gt;`
                      &lt;/tr&gt;
  
              ";
  
          }
      ?&gt;
  &lt;/tbody&gt;
      &lt;/table&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I fully understand that this is not a very secure way of doing this and i would be open to suggestions as to how to do this correctly as i am keen to learn.</p>