Jump to content

including other pages when links pressess


parhat

Recommended Posts

Hi, guys,

I just started to learn php. Here you can see too pages, one is header.php that has menu and header part. the other one is index.php that has the body and some if statement, and some includes. But I don't think this "if statement" method is wrong for this kind of idea.
It's not showing up when I press the any link from the menu.

Can you guys help me?  ???

This is the index.php

[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>dilpar</title>
<link rel="stylesheet" type="text/css" href="default.css"/>
</head>
<body>
<div class="main">

<?php

include("header.php");

if ($home == "true")
include("main.php");

elseif ($about == "true")
include("about.php");

elseif ($bio == "true")
include("bio.php");

elseif ($portfolio == "true")
include("portfolio.php");

elseif ($contact == "true")
include("contact.php");

else
include("main.php");

include("footer.php");
?>

</div>
</body>
</html>[/code]



This is the header.php
[code]<?php

$home = "<a href=\"index.php\"><span>Home</span></a>";
$about = "<a href=\"about.php\"><span>About</span></a>";
$bio = "<a href=\"bio.php\"><span>Bio</span></a>";
$portfolio = "<a href=\"portfolio.php\"><span>Portfolio</span></a>";
$contact = "<a href=\"contact.php\" id=\"last\"><span>Contact</span></a>";

?>
<div class="gfx">
<img src="img/logo.gif" alt="" width="50" height="30" border="0" />
</div>
<div class="menu">

<?php
echo $home;
echo $about;
echo $bio;
echo $portfolio;
echo $contact;
?>

</div>[/code]


Thanks for your help.... ??? ??? ???
Sorry, but that code doesn't make sense. When you click on one of those links you will be taken to that page, it wont be included within index.php

If that is what you really want, try this...

header.php
[code]
      <div class="gfx">
        <img src="img/logo.gif" alt="" width="50" height="30" border="0" />
      </div>
      <div class="menu">
        <a href="#">Home</a>
        <a href="?p=about">About</a>
        <a href="?p=bio">Bio</a>
        <a href="?p=portfolio">Portfolio</a>
        <a href="?p=contact">Contact</a>
      </div>
[/code]

index.php
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>dilpar</title>
    <link rel="stylesheet" type="text/css" href="default.css"/>
  </head>
  <body>
    <div class="main">
<?php
  include 'header.php';
  if (isset($_GET['p'])) {
    switch ($_GET['p']) {
      case 'about':
        include 'about.php';
        break;
      case 'bio':
        include 'bio.php';
        break;
      case 'portfolio':
        include 'portfolio.php';
        break;
      case 'contact':
        include 'contact.php';
        break;
      default:
        include 'main.php';
        break;
    }
  } else {
    include 'main.php';
  }
?>
    </div>
  </body>
</html>[/code]
You can do that just the same way you are passing the p-variable to determine which file you will include.
Make the links in flash with $_GET variables
Example actionScript
[code]
on (press) {
  getURL('http://www.mysite.com/blahblah.php?p=includePage', '_self', 'GET');
}
[/code]

You can intercept the value in your files with the $_GET['p'] variable.

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.