title: PHP : How to echo different case of Mysql result into table?
body: <p>I want to show table like :</p>
  
  <pre><code>|             |  qty | S rank | A rank | B rank | C rank |
  +--------------------------------------------------------+  
  | TODAY       |  12  |   0    |   0    |    0   |    0   |    //THIS CURRENT DATA
  +--------------------------------------------------------+
  |MONTHLY TOTAL| 200  |   1    |   0    |    0   |    0   |    //THIS MONTHLY DATA
  +--------------------------------------------------------+
  </code></pre>
  
  <p>The table above will show after echoing mysql result use PHP. How to combine tWo case become one table after <code>echo</code>? using double <code>$sql</code> or something else use PHP ?
  So far, I'm success during echo current data, but for Monthly data i've become confuse how to deciding which way that should I try to do.</p>
  
  <p>CURRENT DATA script:</p>
  
  <pre><code>..........
  $sql = " SELECT COUNT(Serial_number) AS n, SUM(S) AS S,SUM(A) AS A, SUM(B) AS B, SUM(C) AS C
  FROM inspection_report WHERE Model LIKE 'KD-R306TUND' AND Lot_no LIKE '066A' AND Line LIKE 'FA 01' AND Range_sampling ='087X0001-087X0400' GROUP BY Range_sampling";
  $result=mysql_query($sql) or die(_ERROR26.": ".mysql_error());
  echo "&lt;table border='1' width='500'&gt;";
  echo "&lt;caption&gt;INSPECTION REPORT&lt;/caption&gt;";
  echo "&lt;thead&gt;&lt;tr&gt;";
  echo "&lt;td colspan='3'&gt;&lt;/td&gt;";
  echo "&lt;th&gt;n&lt;/th&gt;&lt;th&gt;S&lt;/th&gt;&lt;th&gt;A&lt;/th&gt;&lt;th&gt;B&lt;/th&gt;&lt;th&gt;C&lt;/th&gt;";
  echo "&lt;/tr&gt;&lt;/thead&gt;";
  echo "&lt;tbody&gt;";
  while($row=mysql_fetch_array($result)){
          echo "&lt;tr&gt;&lt;th rowspan='2'&gt;JUDGE&lt;/td&gt;&lt;td id='acc' bgcolor='grey'&gt;ACCEPT&lt;/td&gt;&lt;th&gt;TODAY&lt;/th&gt;&lt;td&gt;";
          echo $row['n'];
          echo "&lt;/td&gt;&lt;td&gt;";
          echo $row['S'];
          echo "&lt;/td&gt;&lt;td&gt;";
          echo $row['A'];
          echo "&lt;/td&gt;&lt;td&gt;";
          echo $row['B'];
          echo "&lt;/td&gt;&lt;td&gt;";
          echo $row['C'];
          echo "&lt;/td&gt;&lt;/tr&gt;";
          }
  echo "&lt;/tbody&gt;&lt;/table&gt;";
  mysql_close($dbc);
  ?&gt;
  </code></pre>
  
  <p>This query for count MONTHLY data :</p>
  
  <pre><code>SELECT COUNT(Serial_number) AS n, SUM(S) AS S,SUM(A) AS A, SUM(B) AS B, SUM(C) AS C
  FROM inspection_report WHERE Inspection_datetime &lt;=
       ( SELECT DATE(MAX(Inspection_datetime)) FROM inspection_report
         WHERE Model LIKE 'KD-R306TUND' AND Lot_no LIKE '066A'
         AND Line LIKE 'FA 01' AND Range_sampling ='087X0001-087X0400' )
  AND MONTH(Inspection_datetime)=MONTH(CURRENT_DATE) AND Line ='FA 01'
  </code></pre>
  
  <p>could I get the result like above table ?</p>