Jump to content

[SOLVED] Page Include


mme

Recommended Posts

Hi why doesn't this code work ?

 

Its supposed to include the the relevant page with the .html extension except when it is the testimonials page then its a .php extension

 

      <? 

  $pages = array("home","about","where","how","testimonials","contact","site_map");



  $go=$pages[0] . ".html";

   for ($i=0;$i<count($pages);$i++) {

      if (strtolower($_GET['page'])==$pages[$i]) {

        if ($pages[$i]="testimonials") {$go=$pages[$i] . ".php";} else {
	$go=$pages[$i] . ".html";}


        break;

      }

    }

  include($go);

?>

Link to comment
https://forums.phpfreaks.com/topic/135238-solved-page-include/
Share on other sites

Use the == operator for comparisons:

<?php
$pages = array(
"home",
"about",
"where",
"how",
"testimonials",
"contact",
"site_map"
);

$go = $pages[0] . ".html";

for ($i = 0; $i < count($pages); $i++) 
{
if (strtolower($_GET['page']) == $pages[$i]) 
{
	if ($pages[$i] == "testimonials") 
	{
			$go = $pages[$i] . ".php";
	} 
	else 
	{
		$go = $pages[$i] . ".html";
	}
	break;
}
}
include($go);
?>

Link to comment
https://forums.phpfreaks.com/topic/135238-solved-page-include/#findComment-704411
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.