how to avoid last added 2 data in while loop 

```
$counter = 0;
$data=mysql_query("select * from tbl_sub_product");
$cnt = sizeof(mysql_fetch_assoc($data));
while($row= mysql_fetch_assoc($data)) {

if(($counter==$cnt-1) || ($counter== $cnt-2)){

}
 echo $id = $row['id'];
} 

```

is this a correct way.?is there any other way.? please help me