I am looking to add a qty column results fetched from MySQL database. Also I am looking to group the results by center and medicine.
I'd like to show the next results in new row within a HTML table. check this again
SNoMedicineName QTY Center
3 7 3 Bhop
4 7 3 Bhop
5 7 3 Bhop
6 1 2 Bhop
TOTAL QTY2 TOTAL QTY9
6Medicine1CenterBhopalQTY2 3Medicine7CenterBhopalQTY3
//Here i am looking for sno to 1 med name to 7 qty to 9 cent to bhop
then sno to 2 med name to 1 qty to 2 cent to bhop
My code is
<?php
include_once('db.php');
$sql = "SELECT * FROM medical_new ";
if(isset($_Post['submit']));
{
$cent=$_POST['center'];
$sql .= "where center= '{$cent}'";
}
$query=mysql_query($sql) or die (mysql_err());
?>
<table border='1'>
<tr>
<th><b>SNo</b></th>
<th><b>MedicineName</b></th>
<th><b>QTY</b></th>
<th><b>Center</b></th>
</tr>
<?php
while( $row = mysql_fetch_array($query) )
{
echo "<tr>";
echo "<td>" . $row['CustomerID'] . "</td>";
echo "<td>" . $row['MedicineName'] . "</td>";
echo "<td>" . $row['Qty'] . " </td>";
echo "<td>" . $row['Center'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
Can someone give me some tips or suggestions on how to do this? Thanks.
Table
CustomerID MedicineName Date Qty RRP Net RRP MRP Price Net MRP Center
1 1 0000-00-00 3 250 750 360 1080 2
2 3 0000-00-00 3 111 333 211 633 3
3 7 0000-00-00 3 222 666 211 633 Bhop
4 7 10/10/2013 3 222 666 211 633 Bhop