title: MySQL link to return results
body: <p>I have an image that is displayed from a table and I want the user to be able to click the image which directs them to a page that returns the rest of the data for that row. Do I need a php loop for this? I can't quite figure it out. 
  This returns the Last Name, First Name, and an Image:</p>
  
  <pre><code>    &lt;?php
      if (isset($_GET['LastName'])) {
      $ln = $_GET['LastName'];
      }
          include 'connection.php';
          $query = "SELECT * FROM residents WHERE LastName like '$ln%' ";
          $result = mysql_query($query);
  
  
      while($person = mysql_fetch_array($result)) { ?&gt;
      &lt;div class="media col-sm-4"&gt;
           &lt;a class="pull-left" href="redirectionpage.php?&lt;?php echo $person['ID'];?&gt;.php"&gt;
      &lt;img class="media-object" src="upload/&lt;?php echo $person['Picture'];?&gt;"   width="100" height="100"/&gt;
      &lt;/a&gt;
      &lt;div class="media-body"&gt;
       &lt;h4 class="media-heading"&gt;&lt;?php echo $person['LastName'] . ", " . $person['FirstName']; ?&gt;&lt;/h4&gt;
  
     &lt;/div&gt;
      &lt;/div&gt;
      &lt;?php }&gt;?
  </code></pre>
  
  <p>Is the best way to accomplish this by redirecting the user to a new page and using a mysql statement to display the new data?</p>
  
  <p>This is the code for the other page:</p>
  
  <pre><code>    &lt;?php
      //Gets data from the database
          include ('header.php');
          include ('footer.php');
          include ('connection.php');
  
  
  
          $query = "SELECT * FROM residents WHERE ID = LastName LIMIT 1";
          $result = mysql_query($query);
  
  
         while($row = mysql_fetch_array($result)){
         $outputpicture.='&lt;div&gt;&lt;p&gt;&lt;img src="upload/' . $row['Picture'].'" width="450" height="550"/&gt;&lt;/p&gt;&lt;/div&gt;';
         $outputname.= $row['LastName'] . ", " . $row['FirstName']. '&lt;br /&gt;';
         $outputspouse.= $row['Spouse']. '&lt;br /&gt;';
         $outputrelatives.= $row['Relatives']. '&lt;br /&gt;';
         $outputaddress.= $row['Address']. '&lt;br /&gt;';
         $outputbirthday.= $row['Birthday']. '&lt;br /&gt;';
         $outputbegan.= $row['BeganResidence']. '&lt;br /&gt;';
         $outputended.= $row['EndedResidence']. '&lt;br /&gt;';
         $outputformer.= $row['FormerResidence']. '&lt;br /&gt;';
         $outputcareer.= $row['Career']. '&lt;br /&gt;';
         $outputeducation.= $row['Education']. '&lt;br /&gt;';
         $outputmaritalstatus.= $row['MaritalStatus']. '&lt;br /&gt;';
         $outputsiblings.= $row['Siblings']. '&lt;br /&gt;';
         $outputspecialinterests.= $row['SpecialInterests'].'&lt;br /&gt;';
         }
  
  
        ?&gt;
  </code></pre>