$sql="select * from km where devicename='".$_POST['fix']."' and waste='".$_POST['c1']."' group by repair order by Idkm asc";
$query=mysql_query($sql);
$numrows=mysql_num_rows($query);
if($numrows>0)
{
$i=1;
while($row=mysql_fetch_array($query))
{
<?=$row['repair']?>
<?=$row['results']?>
$sql="select devicename,waste,repair,results,count(repair)as num from km where devicename='".$_POST['fix']."' and waste='".$_POST['c1']."' group by devicename,waste,repair,results order by num desc";
$sql="select devicename,waste,repair,results,count(repair)as num from km where devicename='".$_POST['fix']."' and waste='".$_POST['c1']."' group by repair order by num desc";