title: Returning multiple results when only one present in DB
body: <p>Alrighty, so this code has been giving me trouble for the past day or so. All of its duties are working perfectly fine, save for the Tax query. (at least thats the only one thats giving me trouble that i can tell of)...
  as far as i can tell; the code is giving me trouble because their are multiple TUID and UID's that are the same, but don't go to the same user, (EG an ID that == 1 might be User1 or it might be Group1).</p>
  
  <p>I'm not asking for you guys to fix this code, (It seems everytime i post here, someone says 'oh you just want us to fix your code and blah blah blah blah') I'm just curious if anybody has a good work around for this?</p>
  
  <p>I'm getting duplicate rows returned to the query;
  this is what the query returns: <a href="http://gmz1023.com/rowline.PNG" rel="nofollow">http://gmz1023.com/rowline.PNG</a></p>
  
  <pre><code>{
      $sql = "SELECT type FROM bank_transaction LIMIT 25";
      $que = $this-&gt;db-&gt;prepare($sql);
      $que-&gt;bindParam('uid', $uid);
      try{ 
      $que-&gt;execute(); 
      ob_start();
      if($que)
      {
          $id = '1';
          $transaction = '';
          while($row = $que-&gt;fetch())
          {
          /* This is the tricky bit; for each type that is returned, we start another query and pull up that data.&lt;
          /* This may need to be turned into seperate functions later on. however, for now, keep trying to figure out how to get the code to work, 
          /* There's      nor eason why it shouldn't work, as its simple as hell. and yet we keep getting multiple rows in the table.
              */ 
              if($row[0] == 'govt')
              {
                  $sql = "SELECT tuid, uid, balance FROM bank_transaction WHERE type = :type AND uid = :uid";
                  $querty1 = $this-&gt;db-&gt;prepare($sql);
                  $type = 'govt';
  
                  $querty1-&gt;bindParam('type', $type);
                  $querty1-&gt;bindParam('type', $row[0]);
                  $querty1-&gt;bindParam('uid', $uid);
                  try {
                      if($querty1-&gt;execute())
                      {
                          $info = $querty1-&gt;fetch();
                          $to = parent::getUsername($info[0]);
                          $from = parent::getStoryName($info[1]);
                          $balance = $info[2];
                          $transaction .= "&lt;tr&gt;&lt;td&gt;{$id}&lt;/td&gt;&lt;td&gt;{$from}&lt;/td&gt;&lt;td&gt;{$to}&lt;/td&gt;&lt;td&gt;{$balance}&lt;/td&gt;&lt;td&gt;{$row[0]}&lt;/td&gt;&lt;/tr&gt;";
                          $querty1-&gt;closeCursor();
                      }
                  }catch(PDOException $e) { echo $e-&gt;getMessage();}
              }
              if($row[0] == 'business')
              {
                  $sql = "SELECT tuid, uid, balance, date FROM bank_transaction WHERE type = :type AND tuid = :uid OR uid = :uid";
                  $querty1 = $this-&gt;db-&gt;prepare($sql);
                  $type = 'business';
                  $querty1-&gt;bindParam('type', $type);
                  $querty1-&gt;bindParam('type', $row[0]);
                  $querty1-&gt;bindParam('uid', $uid);
                  try {
                      if($querty1-&gt;execute())
                      {
                          $info = $querty1-&gt;fetch();
                          $to = $info[0];
                          $from = $info[1];
                          $balance = $info[2];
                          $date = $info[3];
                          $transaction .= "&lt;tr&gt;&lt;td&gt;{$id}&lt;/td&gt;&lt;td&gt;{$from}&lt;/td&gt;&lt;td&gt;{$to}&lt;/td&gt;&lt;td&gt;{$balance}&lt;/td&gt;&lt;td&gt;{$row[0]}&lt;/td&gt;&lt;td&gt;{$info[3]}&lt;/tr&gt;";
                          $querty1-&gt;closeCursor();
                      }
                  }catch(PDOException $e) { echo $e-&gt;getMessage();}
              }
              if($row[0] == 'tax')
              {
  
                  $sql = "SELECT tuid, uid, balance, date FROM bank_transaction WHERE tuid = :tuid AND type = :type ;";
                  $querty = $this-&gt;db-&gt;prepare($sql);
                  $type = 'tax';
                  $uid = '2';
                  $querty-&gt;bindParam('type', $type);
                  $querty-&gt;bindParam('tuid', $uid);
                  try {
                      if($querty-&gt;execute())
                      {
                          $info = $querty-&gt;fetch();
                          $to = parent::getStoryName($info[0]);
                          $from = parent::getUsername($info[1]);
                          $balance = $info[2];
                          $transaction .= "&lt;tr&gt;&lt;td&gt;{$id}&lt;/td&gt;&lt;td&gt;{$from}&lt;/td&gt;&lt;td&gt;{$to}&lt;/td&gt;&lt;td&gt;{$balance}&lt;/td&gt;&lt;td&gt;{$row[0]}&lt;/td&gt;&lt;td&gt;{$info[3]}&lt;/tr&gt;";
                          $querty-&gt;closeCursor();
                      }
                  }catch(PDOException $e) { echo $e-&gt;getMessage();}
  
              }
              elseif($row[0] == 'personal')
              {
                  $sql = "SELECT tuid, uid, balance FROM bank_transaction WHERE type = :type AND uid = :uid OR tuid = :uid";
                  $querty = $this-&gt;db-&gt;prepare($sql);
                  $type = 'personal';
                  $querty-&gt;bindParam('type', $type);
                  $queryt-&gt;bindParam('uid', $uid);
                  try {
                      if($querty-&gt;execute())
                      {
                          $info = $querty-&gt;fetch();
                          $to = $info[0];
                          $from = $info[1];
                          $balance = $info[2];
                          $transaction .= "&lt;tr&gt;&lt;td&gt;{$id}&lt;/td&gt;&lt;td&gt;{$from}&lt;/td&gt;&lt;td&gt;{$to}&lt;/td&gt;&lt;td&gt;{$balance}&lt;/td&gt;&lt;td&gt;{$row[0]}&lt;/td&gt;&lt;/tr&gt;";
                          $querty-&gt;closeCursor();
                      }
                  }catch(PDOException $e) { echo $e-&gt;getMessage();}
              }
              $id = $id +1;
          }
      return $transaction;
      ob_end_clean();
      }
      else
      {
          echo "ERROR!";
      }
      }catch(PDOException $e) { echo $e-&gt;getMessage(); }  
  }
  </code></pre>
  
  <p>The Database
      tid int(11)         No  None    AUTO_INCREMENT
      uid int(11)         No  None
      tuid    int(11)         No  None
      balance int(11)         No  None
      type    enum('personal', 'govt', 'business', 'tax') latin1_swedish_ci       No  date    datetime</p>