title: connection results (multiple tables) php, mysqli INNER JOIN
body: <p>(Best practice for including many to many results inside each result?)</p>
  
  <p>Each post has a number of resources. I'm trying to show them.
  It works separately, like this:</p>
  
  <p>All connections between resources and posts:</p>
  
  <pre><code>   $result = $mysqli-&gt;query("SELECT *
          FROM kopplaKontorsplatsResurser
          INNER JOIN resurser
          ON kopplaKontorsplatsResurser.resurs_id=resurser.id
          ");
  
      $num_results = mysqli_num_rows($result);
      for($i=0; $i&lt;$num_results; $i++) {
      $row = $result-&gt;fetch_array(MYSQLI_ASSOC);
      echo 'Resource with id: '.$row[resurs_id];
      echo '&lt;br&gt;';
      echo 'Is connected to the post: '.$row[kontorsplats_id];
      echo '&lt;br&gt;';
      echo 'What resource is this? '.$row[resurs];;
      echo '&lt;br&gt;&lt;br&gt;';
      }
  </code></pre>
  
  <p>This is how I get info about each post(kontorsplats)</p>
  
  <pre><code>  $result = $mysqli-&gt;query("SELECT *
                   FROM kontorsplatser
                   INNER JOIN geo_orter
                   ON kontorsplatser.ort_id=geo_orter.ort_id
                   ");
      $num_results = mysqli_num_rows($result);
  
      for($i=0; $i&lt;$num_results; $i++) {
      $row = $result-&gt;fetch_array(MYSQLI_ASSOC);
  
      echo '&lt;div class="kontorsplats"&gt;';
      $arbetsplatsensID = $row[id];
      $rubriken = $row[rubrik];
      $ort_id = $row[ort_id];
      $ort = $row[ortnamn];
  
      echo '&lt;h4&gt;'.$rubriken.'&lt;/h4&gt;';
      echo '&lt;h5&gt;&lt;a href=""&gt;'.$ort.'&lt;/a&gt;&lt;/h5&gt;';
  
         ---&gt; Show the connected resources here. :D &lt;------
  
      echo '&lt;/div&gt;';
  </code></pre>
  
  <p>I'm considering creating an array with all the resources and their connections and loop through it for every div, but would that be the most efficient way?</p>
  
  <p>Interresting on including aliases:
  <a href="http://forums.devshed.com/oracle-development-96/alias-in-inner-join-query-512683.html" rel="nofollow">devshed</a></p>