title: Getting values from mysql tables
body: <p>I'm new at using sql but I have a problem that I just can't seem to solve. I have four tables: T_Item, t_trade, T_sender_trade and T_receiver_trade like this:</p>
  
  <pre><code>T_Item
  (itemID, name, category, description, description);
  
  T_Trade
  (tradeID, date, senderID, receiverID);
  
  T_sender_trade
  (tradeID, senderItemID) - both foreign keys from the previous tables
  
  T_receiver_trade
  (tradeID, receiverItemID) - as in T_sender_trade
  </code></pre>
  
  <p>It is meant that a sender and a receiver trade two items. What I want to do is create a table in html with php, with the following information:</p>
  
  <ul>
  <li>description of the item from the sender</li>
  <li>description of the item from the receiver</li>
  <li>date (trade's date)</li>
  </ul>
  
  <p>I'm using a Class Trade as it is requires by my teacher.
  I used the following code in the class:</p>
  
  <pre><code>&lt;?php
      require_once '../utils/ligabd.php'; (uses the connection to the mysql in another class)
  
  Class Trade
      {
              public $tradeID;
          public $date;
          public $senderID;
          public $receiverID
  
  
          public function __construct($date = null, $senderID= null, $receiverID=null) {
  
              $this-&gt;date= $date;
                  $this-&gt;senderID= $senderID;
              $this-&gt;receiverID= $receiverID;     
                                  }
  
      public static function load($tradeID) {
      $result = mysql_query("SELECT * FROM T_Trade");
      if (!$result) {
          die('Troca não existente ' . mysql_error());
      }
      $row = mysql_fetch_assoc($result);
      if ($row) {
        $t = new Trade();
        $t-&gt;tradeID = $row["tradeID"];
        $t-&gt;date = $row["date"];
        $t-&gt;senderID=$row["senderID"];
        $t-&gt;receiverID=$row["receiverID"];
        return $t;
      } else {
        return NULL;
      }
      }
  
  public static function returnsSenderItem($tradeID) {
      $result = mysql_query("SELECT * FROM T_Item, T_sender_trade where T_sender_trade.tradeID= $tradeID AND T_sender_trade.senderItemID =T_Item.ItemID");
  
  if(!$result) {
  die ('Trade not found ' .mysql_error());
  }
  $rows=Array();
      while ($row = mysql_fetch_assoc($result)) {
      $rows[]=$row;
              }
              return $rows;
              } 
  </code></pre>
  
  <p>And the same for the receiver's Item.
  In the php code i use (just to get one item's description because I was able to get the ttade's date):</p>
  
  <pre><code>include '../classes/troca.php';
  $tradeID=$_GET[tradeID];
  $trade=Trade::load($tradeID);
  echo $trade-&gt;date; 
  $sender=Trade::returnsSenderItem($tradeID);
  foreach($senderr as $s):
  echo $s['name'];
  endforeach;
  </code></pre>
  
  <p>And I am supposed to use a code like this to make my table. The thing is the program isn't able to find the data from T_Item.. what should I change in my class/php so it does?
  Thank you.</p>