Jump to content


Photo

else if not echoing


  • Please log in to reply
3 replies to this topic

#1 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 01 July 2006 - 08:07 AM

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.
<?php
$filename = "forum.php";
$title = "Forum"; 
include("includes/construct.php");
include("includes/main.php");
?>

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.php

Here is the construct.php:

<?php
$content = " 
  <div class=\"story\">
   <h3>$title is Coming Soon</h3>
   <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This page is under construction 
    </p>
	<p>
    &nbsp;&lt;--------------------------------------------------------------------------------&gt;
   </p>
  </div>"
?>

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.
<!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>

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.
  <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>

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
  <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>"
?>

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 forum.php

Any suggestions would be great.   


Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 01 July 2006 - 08:25 AM

well i went to your website and it seems to be working...
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 01 July 2006 - 08:27 AM

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.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 01 July 2006 - 08:46 AM

would it make the load time any faster , or is this a better way, If I added in the forum.php something like this
<?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>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This page is under construction 
    </p>
	<p>
    &nbsp;&lt;--------------------------------------------------------------------------------&gt;
   </p>
  </div>";
 else echo("$content");   
?>        
</div> 
<!--end content -->[/code] 
[/code]

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users