<?php include("../../include/dbconnect.php"); 
$result = mysqli_query($conn,"select distinct account_year from tranid order by account_year ") or die(mysqli_error());
while($row = mysqli_fetch_row($result))
{
	$tresult = mysqli_query($conn,"select max(trans_id) from tranid where account_year = '$row[0]' ") or die(mysqli_error());
	while($trow = mysqli_fetch_row($tresult))
	{
		$query = "delete from tranid where account_year = '$row[0]' and trans_id < $trow[0] ";
		mysqli_query($conn,$query) or die(mysqli_error());
		echo("$query<br>");
	}
}





