tomfmason Posted July 1, 2006 Share Posted July 1, 2006 I am having a bit of issue with echo. I am sure that I made a simple systanx error. I don't understand what I did wrong. It was working fine untill I added a seperate php file that would let people know that the site was under construction ok here we go.I will start with forum.php. [code]<?php$filename = "forum.php";$title = "Forum"; include("includes/construct.php");include("includes/main.php");?>[/code]Simple I know but it is only temporary. Now $title is supposed to be used in three places. The construct.php Which Works. The header.php(simple breadcrumb) and the navbar.phpHere is the construct.php:[code]<?php$content = " <div class=\"story\"> <h3>$title is Coming Soon</h3> <p> This page is under construction </p> <p> <--------------------------------------------------------------------------------> </p> </div>"?>[/code]This is another simple page. As you can see $title is printed at the top of the page. This works just fine.Now I will post the main.php which is the main layout for my site.[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><!-- DW6 --><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title><?php echo("$title"); ?></title><link rel="stylesheet" href="main.css" type="text/css"></head><body bgcolor="#707070"><div id="master"> <div id="masthead"> <?php include("header.php"); ?> </div> <div id="navBar"> <?php include("navbar.php"); ?> </div> <!--end navBar div --> <div id="headlines"> <?php include("headlines.php"); ?> </div> <!--end headlines --> <div id="content"> <?php echo("$content"); ?> </div> <!--end content --> <div id="siteInfo"> <?php include("footer.php"); ?> </div></div> <br> </body></html>[/code]As you can see $content is passed from construct.php. This is only temporay, untill I code the forum $content in forum.php. Now here is the header.php This is were things stop working the way I want.[code] <div id="header"> <object type="application/x-shockwave-flash" width="770" height="200" data="header.swf"> <param name="movie" value="../images/header.swf" /> </object> </div> <div id="breadCrumb"> <?php if ($filename=="index.php")echo " <a href=\"index.php\">Home</a>";else echo " <a href=\"http://www.owpt.biz/index.php\">Home</a> / <a href=\"$filename\">$title</a>"?> </div>[/code]As you can see if the person is on index.php it is supposed to print home and if they are at a different page it is supposed to print home / $title . Simple, yes but it still dosn't work. The only one that prints is the first one. Now we are on to the navbar.php[code] <div id="search"> <form action="#"> <label>search</label> <input name="searchFor" type="text" size="10"> <input name="goButton" type="submit" value="go"> </form> </div> <div id="sectionLinks"> <h3>Links</h3> <ul> <li><a href="index.php">Home</a></li> <li><a href="account.php">My account</a></li> <li><a href="contact.php">Contact Us</a></li> <li><a href="catalog.php">Catalog</a></li> <li><a href="forum.php">Forum</a></li> <li><a href="tutorials.php">Tutorials</a></li> </ul> </div> <?php if ($title=="Tutorials")echo " <div class=\"relatedLinks\"> <h3>$title</h3> <ul> <li><a href=\"#\">Html</a></li> <li><a href=\"#\">Css</a></li> <li><a href=\"#\">Php</a></li> <li><a href=\"#\">Flash</a></li> <li><a href=\"#\">Xampp</a></li> <li><a href=\"#\">Wamp</a></li> </ul> </div>";elseif ($title=="Forum")echo " <div class=\"relatedLinks\"> <h3>$title Catagories</h3> <ul> <li><a href=\"#\">General</a></li> <li><a href=\"#\">Apache</a></li> <li><a href=\"#\">MySql</a></li> <li><a href=\"#\">Html</a></li> <li><a href=\"#\">Css</a></li> <li><a href=\"#\">Php</a></li> <li><a href=\"#\">Flash</a></li> <li><a href=\"#\">Xampp</a></li> <li><a href=\"#\">Wamp</a></li> </ul> </div>"?>[/code]Here it is supposed to print more links if the $title is forum or tutorials. I plan on, later getting the list from a data base but for now this will work just fine.Neither the breadcrumbs nor the navbar are working correctly. When I few the source code there is an empty space where the extra navbar is supposed to be. Here is a link to the [url=http://www.owpt.biz/forum.php]forum.php[/url]Any suggestions would be great. Quote Link to comment https://forums.phpfreaks.com/topic/13364-else-if-not-echoing/ Share on other sites More sharing options...
.josh Posted July 1, 2006 Share Posted July 1, 2006 well i went to your website and it seems to be working... Quote Link to comment https://forums.phpfreaks.com/topic/13364-else-if-not-echoing/#findComment-51583 Share on other sites More sharing options...
tomfmason Posted July 1, 2006 Author Share Posted July 1, 2006 It must have been my computer cacheing the site. When I clicked the link to forum.php it was working just fine...lol I spent about two hours racking my brain tryin to figure this out. Quote Link to comment https://forums.phpfreaks.com/topic/13364-else-if-not-echoing/#findComment-51585 Share on other sites More sharing options...
tomfmason Posted July 1, 2006 Author Share Posted July 1, 2006 would it make the load time any faster , or is this a better way, If I added in the forum.php something like this[code]<?php$construction = "true";$filename = "forum.php";$title = "Forum"; include("includes/construct.php");include("includes/main.php");?> [code] and changed the content area in main.php to this[code]<div id="content"><?php if ($construction == "true") echo"$content = " <div class=\"story\"> <h3>$title is Coming Soon</h3> <p> This page is under construction </p> <p> <--------------------------------------------------------------------------------> </p> </div>"; else echo("$content"); ?> </div> <!--end content -->[/code] [/code][/code] Quote Link to comment https://forums.phpfreaks.com/topic/13364-else-if-not-echoing/#findComment-51591 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.