i meant to set $last_id at the end of that loop... oops