February 26, 200917 yr hey all. i am having trouble with my page definitions. here is my pagedefinitions.php <?php if (!isset($_GET['p'])){$page="home";} else if ($_GET['p'] == "home"){$page=$_GET['p'];} else if ($_GET['p'] == "weightloss"){$page=$_GET['p'];} else if ($_GET['p'] == "musclebuilding"){$page=$_GET['p'];} else if ($_GET['p'] == "toning"){$page=$_GET['p'];} else if ($_GET['p'] == "forums"){$page=$_GET['p'];} ?> here is my include in the index.php <?php include "pagedefinitions.php";?> the site is www.changemyworkout.com. i am trying to have everything change only in div class="holder". any thoughts? thanks guys. peace and love. mike.
February 27, 200917 yr I'm not actually sure what you're asking. You say you're having problems with "page definitions" but that's not a standard term I'm familiar with. I infer that the "p" query parameter is the name of the page to display, but your code in pagedefinitions.php is a bit elaborate when all you're doing is $page=$_GET['p'] in every case. Perhaps you could store the names of valid pages in an array, then use in_array() to see if $_GET['p'] is in that array and if not, set $page="home"? That'd be just three lines for any number of pages. In fact, it's this: $PAGES = array ( "home", "weightloss", "musclebuilding" ); // just extend this list for each new page $page = $_GET['p']; if(!in_array($page,$PAGES)) $page="home"; You also say "trying to have everything change on in div ...", which if I read correctly means you have an HTML <div> whose content will change depending on $page? Which sounds trivial, except you don't say where that content is coming from, or how it is to be selected! I think we need some more detail to be of further use.
February 27, 200917 yr Author the second part is my problem. i want the only part of the site to change is inside the big middle square. i have other php files on the server to pull in. im just not sure what the correct code would be to do this. thanks charles for the above, i wasn't quite sure how to put it. thanks in advance guys. nvm fixed it thanks though.
March 2, 200917 yr goldfingerler, i use this exact same method to run the applications i make except im using a mysql database which i find abit easier to manage. also i use page alias's instead of using filenames in the url, ive got a setup along the lines of $_GET['page'] holds the page name/key i then use that to query the DB fetching the real filename (normally prefixed with php_p_ (first bit is the lang, second bit stands for page, c for class or i for inc files)) along with the meta data and other page persific settings like cache settings, SE bot index/noindex values, css files, javascript files etc (witch can all be cached). i know you have solved your issue but thought this would be food for thought
Create an account or sign in to comment