jameshurrell Posted February 23, 2009 Share Posted February 23, 2009 I'm a complete novice at PHP, but I do have some limited coding experience. I have a static HTML based website that I'm in the process of converting to PHP - the reason being that I want to take advantage of the ability to include headers and footers in pages - i.e. rather than having to modify EACH page, simply modify the footer.pph (for example). I have managed quite well so far and have created and index.php that pulls in a header.php, a sidebar.php and a footer.php using the include function. This all works on my hosted space. However I'm stumped on how to pull in the main content for each page. My existing website has a tabbed menu, so I'd like to be able to do the same - i.e. each tab has identical header, footer and sidebar, but different main content. I have seen examples "in the wild" that use a syntax like the following in the browser: http://www.website.com/index.php?p=accommodation http://www.website.com/index.php?p=prices using the following type URL in each tab: <a href="index.php?p=accommodation"> How would I go about this? I assume that the content for each tab would need to be stored in individual HTML or PHP pages, but it's the pulling in bit I don't understand... i.e. the syntax required to do this. Can anyone help (or indeed understand what I am rabbitting on about)? Thanks. Quote Link to comment Share on other sites More sharing options...
sloth456 Posted February 23, 2009 Share Posted February 23, 2009 Those kind of sites use the $_GET variable combined with a switch statement to display different content depending on the variable in the URL. Go research Quote Link to comment Share on other sites More sharing options...
tibberous Posted February 23, 2009 Share Posted February 23, 2009 $p = $_REQUEST['p']; if($p == 'accommodation') include ("accommodation.php"); else if($p == 'prices') include ("accommodation.php"); else include ("404.php"); Quote Link to comment Share on other sites More sharing options...
jameshurrell Posted February 24, 2009 Author Share Posted February 24, 2009 Both: many thanks indeed. This works perfectly. It is like having the light switched on. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.