title: PHP Output multiple tables and its values in one table
body: <p>I need to show you step by step what I've done so far and what the output I am looking for to happen.</p>
  
  <p>First of all I have a table called <strong>stores</strong> as follows :</p>
  
  <pre><code>id | store_name
  1    S1
  2    S2
  3    S3
  4    S4
  </code></pre>
  
  <p>And EACH store_name has its own table that contains item number, qty, cost, sell price and date - One of them as follows :</p>
  
  <pre><code>Table Name : S1
  id | item_no | qty | cost | sell | date
  1      b1001   10     6      12     2015-3-31
  2      b1002   12     6      12     2015-3-31
  3      b1003   6      3      6      2015-3-30
  4      b1004   4      5      10     2015-3-30
  </code></pre>
  
  <p>And so on for each store_name table.</p>
  
  <p>What I'm aiming for is that I need an output to compare each Item number how many qty for each store and list them next to each other as follows :</p>
  
  <pre><code>item_no | cost | sell | S1 | S2 | S3 | S4
  b1001     10     12    10     9    8     N/A
  b1002     6      12    6      3    N/A   N/A
  b1003     3      6     6      6    N/A   12
  b1004     5      10    4      N/A  10    10
  </code></pre>
  
  <p>Please note, the above stores are chosen up by the user request (it could be one store name, or could be all of them) as follows:</p>
  
  <pre><code>&lt;form method="POST" action="Somewhere.php"&gt;
  //Looping To show how many stores
  &lt;input type=checkbox name=store[] value={$row['stores_name']} style='width:20px; height:20px;'&gt;{$row['stores_name']}
  //End of Looping
  &lt;/form&gt;
  </code></pre>
  
  <p>After submitting to Somewhere.php , we have to find out which store selected by doing foreach loop:</p>
  
  <pre><code>$allstore = $_POST['store'];
  
     foreach ($allstore as $store=&gt;$value) {
  
  //Don't Know what code should be here
  
  }
  </code></pre>
  
  <p>I've tried doing my own way, but it lists store_name tables on top of each others, by which its not what I aimed for. Is there a way to do it ? Any other suggestions?</p>
  
  <p><em>Please Note</em>: <strong>COST</strong> and <strong>SELL prices</strong> are the same for all stores!</p>