Php Include navigation

So I basically have a system where there’s a table of pages which have specific ids when clicked you are sent to a new page and the id added to the url. On this page I have a navigation that needs to be included on all of this section as there is more than one page in each sub page. My first thought was having my navigation in a PHP include file and then as this nav is always on a page where the id is in the url pull the url into the main page and the include can read this id (this part seems to work great) but now whenever I make a new page and do the exact same thing the nav buttons don’t work until I messed around uploading and resaving files etc and another new page im still trying to get working is a session a better way forward or could this be a cache error or something?