I have index.php contain variables, then this loads up a template page that calls the variables... now how do you have a page like header.php then have a variable from that page get called?
Also every page is different in that some pages have 5 tables, some have 3. how could I code this to work out? I have a template and need it to call a variable that can contain the code, but how would it know to add another line?
It's all about scope [us3.php.net], not just a mouthwash any more.
Basically, any variable that is defined in the main file or a file that was folded into the main file with include() or require() will be available downstream (i.e. after the point it was included).
Within functions, the scope is local, meaning the variable is only available within the function. Typically, to get a single value out of a function, you use the 'return' statement to return a value.
If you can read through the manual and maybe find some other pages (search on "variables scope php") to help you get the basics down, a lot of other threads on templates will become much, much clearer to you.