get first and last ids from db and create link for both