what i need is a single set of output for each procedures, but my this query is giving me 2-3 sets of answers, between this time period.. i need distinct set of answers..
if(isset($_POST['submit']))
{
$to= $_POST['to'];
$too = date("d/m/y",strtotime($_POST['to']));
$from= date('Y-m-d');;
echo " <br><h2> PROCEDURE REPORTS UPTO <b>'$too' </b> </h2>";
$p =array();
$query = mysqli_query($con,"SELECT COUNT(pro) FROM ivf WHERE DATE(epd) >='$from' and DATE(epd) <='$to' GROUP BY pro");
$result1 = mysqli_query($con,"SELECT * FROM ivf WHERE DATE(epd) >='$from' and DATE(epd) <='$to'GROUP BY pro");
while ($row=mysqli_fetch_array($result1))
{
$row1=mysqli_fetch_array($query);
echo "<td align='center' width='200'>" . $row[2] . "</td>";
echo "<td align='center' width='100' >" .$row1[0]. "</td>";
$p[]=$row1[0];
$a[]=$row[2];
echo"</tr>";
}
echo"</table>";
echo" <br><br><br><br>";
echo" <h2>STOCK REPORT</h2>";
$result = mysqli_query($con,"SELECT DISTINCT * FROM phar
JOIN med
ON med.iname = phar.iname
JOIN ivf
ON phar.pro = ivf.pro
WHERE DATE(ivf.epd) >='$from' and DATE(ivf.epd) <='$to'");
echo "<td align='center'>Medicine Name</td>
<td width='100' align='center'>Procedure</td>
<td width='100' align='center'>Stock in Hand</td>
<td width='100' align='center'>Required Quantity</td></tr> ";
echo "</tr>";
while($row2=mysqli_fetch_array($result))
{
echo "<tr>";
$inme =array();
$stk[]=$row2['stock'];
$inme[]=$row2['iname'];
for ($i = 0; $i < count($inme); $i++)
{
echo "<td align='center' width='200'>" . $row2[1] . "</td>";
echo "<td align='center' width='200'>" . $row2['pro'] . "</td>";
echo "<td align='center' width='50'>" . $row2['stock'] . "</td>";
echo "</tr>";
}
}
echo "</table>";
mysqli_close($con);
}
PROCEDURE REPORTS UPTO '31/05/14'
Procedure Name Total Procedures
Andrology Procedure 1
Ovum Pick up 5
Tesa Procedure 2
*****************************************************
5ml round bottom tube Andrology Procedure 6
Sample Container Andrology Procedure -47
14ml round bottom tube Ovum Pick up 250
14ml round bottom tube Ovum Pick up 250
14ml round bottom tube Ovum Pick up 250
14ml round bottom tube Ovum Pick up 250
14ml round bottom tube Ovum Pick up 250
4 well dish Ovum Pick up 0
4 well dish Ovum Pick up 0
4 well dish Ovum Pick up 0
4 well dish Ovum Pick up 0
4 well dish Ovum Pick up 0
5ml round bottom tube Tesa Procedure 6
5ml round bottom tube Tesa Procedure 6
Falcon(3002) Tesa Procedure 266
Falcon(3002) Tesa Procedure 266