quinreisen Posted June 24, 2010 Share Posted June 24, 2010 Say I have an index.php with a menu with 3 links titled: link1 link2 link3 and i have a content div with an include that is "link1.php" as default. So that when I click on "link2" now it refreshes the page and the link1 content has been replaced with link2 content however it's still using the same index.php This would allow me to have one template page and the includes would only need to have the basic information within them. I know this isn't a super tough question compared to some but any help would be appreciated. I want to stay away from JS and AJAX due to SEO issues. Link to comment https://forums.phpfreaks.com/topic/205771-how-do-i-update-an-include-source/ Share on other sites More sharing options...
ChemicalBliss Posted June 24, 2010 Share Posted June 24, 2010 If you notice at the top of most pages there is the link to the page with a ? after, then variables such as "action" or "id", this is a simple template that should get you started: <?php // Switch statements are like glorified if statements; Switch ($_GET['page']){ // The default value will be used if none of the cases match what is in the variable default: include("default.php"); break; // If the "page" parameter in the link ($_GET) is "link1": case "link1": include("link1.php"); break; // You can put whatever you want as the value: case "member": include("link2.php"); break; } ?> This can be thought of as each case statement being similar to: <?php if($_GET['page'] == "link1"){ include("link1.php"); }elseif($_GET['page'] == "member"){ include("link2.php"); }else{ include("default.php"); } ?> Say you name the script "index.php", located at "somedomain.com" the urls would be: www.somedomain.com/index.php - default page www.somedomain.com/index.php?page=link1 - link1 www.somedomain.com/index.php?page=member - link2 Hope This Helps, -cb- Link to comment https://forums.phpfreaks.com/topic/205771-how-do-i-update-an-include-source/#findComment-1076780 Share on other sites More sharing options...
quinreisen Posted June 24, 2010 Author Share Posted June 24, 2010 Thank you for your quick reply... that helped out a ton. Just a quick side note, do you know if this would be search engine friendly? would the crawlers locate the other pages correctly? If you don't know it's not a big deal. Thank you again I'm going to give this a shot. Link to comment https://forums.phpfreaks.com/topic/205771-how-do-i-update-an-include-source/#findComment-1076788 Share on other sites More sharing options...
ChemicalBliss Posted June 24, 2010 Share Posted June 24, 2010 Crawlers Scan for any links, simply yes, google will scan those links. Though; For best results you would use a PHP Module called "mod_rewrite", for more information on mod_rewrite i suggest googling "php mod_rewrite tutorial". This will basically allow you to use this sort of syntax: somedomain.com/page/link1 This is easier for search engines and maximises your websites usablility and readability. Hope this helps, -cb- Link to comment https://forums.phpfreaks.com/topic/205771-how-do-i-update-an-include-source/#findComment-1076796 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 The mod_rewrite is an Apache web server module, not a PHP module. Ken Link to comment https://forums.phpfreaks.com/topic/205771-how-do-i-update-an-include-source/#findComment-1076806 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.