title: php link trigger for updating a table
body: <p>I created a code so that it ranks a list of pet names ordered by their ages. How can I code it so that once the user clicks on the petname, it updates the viewpet column with the petid from the petcatalog table so that once they are directed to the viewbio.php page, the viewbio.php page will have the petid to retrieve the info for that specific pet? Below is the code. I just can't get it to the UPDATE viewpet column with the pet's specific petid once the user click on that pet's name.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$sessionid = $_SESSION['uid'];
  $info = $conn-&gt;prepare("SELECT `petname`,`age`,`petid` FROM `data` WHERE id = :id ORDER       BY `age` DESC");
  $info -&gt;bindParam(':id', $sessionid , PDO::PARAM_INT);
  $info-&gt;execute();
  
  
   $rank = 0;
   $last_score = false;
   $rows = 0;
  
  
   while ($userinfo = $info-&gt;fetchobject()) {
  
  $rows++;
  if( $last_score!= $userinfo-&gt;age ){
    $last_score = $userinfo-&gt;age;
    $rank++;
  }
  
  
  echo "&lt;b&gt;$rank&lt;/b&gt; . &lt;a href='viewbio.php'&gt; $userinfo-&gt;petname &lt;/a&gt; &amp;nbsp&amp;nbsp&amp;nbsp        &lt;b&gt;Age:&lt;/b&gt;   $userinfo-&gt;age &amp;nbsp&amp;nbsp&amp;nbsp &lt;b&gt;Pet ID:&lt;/b&gt; $userinfo-&gt;petid    &lt;/br&gt;";
  
  if (isset($_GET['viewbio.php']))
  {
  $sessionid = $_SESSION['uid'];
  
  $q = $conn-&gt;prepare("UPDATE petcatalog SET viewpet = :viewwrestler WHERE id = :id");
  $q-&gt;bindParam(':id', $sessionid, PDO::PARAM_INT);                                                  
  $q-&gt;bindParam(':viewpet',$userinfo-&gt;petid , PDO::PARAM_INT);                                                   
  $q-&gt;execute();
  }
  </code></pre>