I want to display a table that looks like this from a Mysql query using PHP:
Vendor Name
Item Not to Drawing Item Defective Incorrect Item Received Other
9 2 3 5
Vendor Name
Item Not to Drawing Item Defective Incorrect Item Received Other
2 4 5 7
etc..
Here is my code....
<?php
$con = mysql_connect("localhost","xxx","xxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("qa", $con);
$result = mysql_query("SELECT Vendor, Sum(draw), Sum(defective), Sun(received), Sum(other) FROM qa_reports Group by Vendor Order by Vendor ASC");
echo "<table>
<tr>
<th>Item not to Drawing</th>
<th>Item Defective</th>
<th>Incorrect Item Received</th>
<th>Other</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Sum(draw)'] . "</td>";
echo "<td>" . $row['Sum(defective)'] . "</td>";
echo "<td>" . $row['Sum(received'] . "</td>";
echo "<td'>" . $row['Sum(other)'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
Not sure how to get the above results formatted as such.
I've done this with CFML but am new to PHP and can not grasp how to list results in a table grouped by a field.