title: Multiple left joins, how to output in php
body: <p>I have 3 tables I need to join.  The contracts table is the main table, the 'jobs' and 'companies' table are extra info that can be associated to the contracts table.</p>
  
  <p>so, since I want all entries from my 'contracts' table, and the 'jobs' and 'companies' data only if it exists, I wrote the query like this....</p>
  
  <pre><code>$sql = "SELECT * FROM contracts
          LEFT JOIN jobs ON contracts.job_id = jobs.id
          LEFT JOIN companies ON contracts.company_id = companies.id
          ORDER BY contracts.end_date";
  </code></pre>
  
  <p>Now how would I output this in PHP?  I tried this but kept getting an undefined error "Notice: Undefined index: contracts.id"...</p>
  
  <pre><code>$sql_result = mysql_query($sql,$connection) or die ("Fail.");
  
  if(mysql_num_rows($sql_result) &gt; 0){
  
      while($row = mysql_fetch_array($sql_result))
      {
         $contract_id = stripslashes($row['contracts.id']);
         $job_number = stripslashes($row['jobs.job_number']);
         $company_name = stripslashes($row['companies.name']);
      ?&gt;
          &lt;tr id="&lt;?=$contract_id?&gt;"&gt;
             &lt;td&gt;&lt;?=$job_number?&gt;&lt;/td&gt;
             &lt;td&gt;&lt;?=$company_name?&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;?  
      }
  }else{
      echo "No records found";
  }
  </code></pre>
  
  <p>Any help is appreciated.</p>