I want to show table like :
| | 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
+--------------------------------------------------------+
The table above will show after echoing mysql result use PHP. How to combine tWo case become one table after echo? using double $sql 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.
CURRENT DATA script:
..........
$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 "<table border='1' width='500'>";
echo "<caption>INSPECTION REPORT</caption>";
echo "<thead><tr>";
echo "<td colspan='3'></td>";
echo "<th>n</th><th>S</th><th>A</th><th>B</th><th>C</th>";
echo "</tr></thead>";
echo "<tbody>";
while($row=mysql_fetch_array($result)){
echo "<tr><th rowspan='2'>JUDGE</td><td id='acc' bgcolor='grey'>ACCEPT</td><th>TODAY</th><td>";
echo $row['n'];
echo "</td><td>";
echo $row['S'];
echo "</td><td>";
echo $row['A'];
echo "</td><td>";
echo $row['B'];
echo "</td><td>";
echo $row['C'];
echo "</td></tr>";
}
echo "</tbody></table>";
mysql_close($dbc);
?>
This query for count MONTHLY data :
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 <=
( 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'
could I get the result like above table ?
From your suggested structure, it contain 3 rows and 6 fields. Now, let’s get back to Basic HTML 101.
To create a table, you need:
To create row and columns, you need:
For more information about how to create HTML table.
Now, back to your case. You already create the first and second rows and by this, you should already understand how to do it.
So, when you need to append another table row, all you have to do is insert the table row code.
Just before:
You do the second (monthly) query and echo it’s value, eg: