parhat Posted November 18, 2006 Share Posted November 18, 2006 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.... ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/27651-including-other-pages-when-links-pressess/ Share on other sites More sharing options...
trq Posted November 18, 2006 Share Posted November 18, 2006 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.phpIf 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] Link to comment https://forums.phpfreaks.com/topic/27651-including-other-pages-when-links-pressess/#findComment-126489 Share on other sites More sharing options...
parhat Posted November 18, 2006 Author Share Posted November 18, 2006 Thanks alot. ;) Link to comment https://forums.phpfreaks.com/topic/27651-including-other-pages-when-links-pressess/#findComment-126556 Share on other sites More sharing options...
parhat Posted November 21, 2006 Author Share Posted November 21, 2006 Hi, I have another question about this. What is my menu is made in by flash. And that flash is in header.php how is that works & how can I able to grab that links info from flash? ??? Link to comment https://forums.phpfreaks.com/topic/27651-including-other-pages-when-links-pressess/#findComment-127833 Share on other sites More sharing options...
CheesierAngel Posted November 21, 2006 Share Posted November 21, 2006 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. Link to comment https://forums.phpfreaks.com/topic/27651-including-other-pages-when-links-pressess/#findComment-127836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.