Jump to content


Photo

help


  • Please log in to reply
8 replies to this topic

#1 kriffer

kriffer
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 June 2006 - 04:11 AM

im new to php, im just learnin this and css .. i tried to do somethig which i thought was simple but am having a problem with... ok heres the problem.. im makin a menu.. but the files arent coming up on the page when you click on the link so this is my menu
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="?" id="current">Home</a></li>
<li><a href="forums">Forums</a></li>
<li><a href="?x=servers">Servers</a></li>
<li><a href="?x=matches">Matches</a></li>
<li><a href="?x=about_us">About Us</a></li>
</ul>
</div>
and this is the php in my page
<?php
if($x=="" ){include"home.php";}
else{include"$x.php";}
?>
so now when i want to goto the Servers page or the Matches page, it just displays it in the url like this
http://www.kriffer.biz/beta/?x=servers
so whats the problem?

#2 .josh

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

Posted 22 June 2006 - 04:15 AM

cuz that's what you put in the href in your link tags. try adding index.php?x=servers etc.. or whatever your main page (home, index, whatever) is.

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 kriffer

kriffer
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 June 2006 - 04:24 AM

ok that worked. yess. but now take for example this site.... www.mwnx.net click on either downloads or network it doesnt matter. look at the url... it doesnt include like index.php or downloads.php like , now that i just inserted the page it shows up like this sites url with index.php?showtopic=96453

#4 .josh

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

Posted 22 June 2006 - 04:33 AM

please try to explain your question a little more. i don't think i fully understand what you mean.
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 :)

#5 kriffer

kriffer
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 June 2006 - 05:32 AM

ok goto www.kriffer.biz/beta .... ok the whole point of
<?php
if($x=="" ){include"home.php";}
else{include"$x.php";}
?>
this was to keep the banner and footer not change at all.. and only that content the "include' i.e. include"home.php"; change only that data.. so if you clicked on servers or something else on that menu.. it will go and display the data.. right now it just links to the files i just want it to change the inside data the content that says servers. or matches. or about us. or whatever..

#6 .josh

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

Posted 22 June 2006 - 05:47 AM

okay so let's say you have an index.php and it has 3 sections:

example index.php
<html>
<head></head>
<body>

<!-- header content: let's put your links here, as an example -->
<div>
   <a href = 'index.php?x=home'>home</a> |  
   <a href = 'index.php?x=forum'>forum</a> |
   <a href = 'index.php?x=contact'>contact</a>
</div>

<!-- main content -->
<div>
   <?php
      if ($_GET['x']) {
          include($_GET['x'] . '.php');
      } else {
          include('home.php');
      }
   ?>
</div>

<!-- footer content -->
<div>
   footer stuff here
</div>

</body>
</html>
now, this is just a simple example. there are some major security flaws in this. for example, you will at the very least want to create an array of acceptable values of x and only include ($_GET['x'] . '.php'); if $_GET['x'] matches one of the values in the array.
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 :)

#7 kriffer

kriffer
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 June 2006 - 05:50 AM

ok remember im new to all this.. but ok.. see that php looks different then the php i had in there.. so thats what your suggesting i go with and ok here if this helps any better.. what i was trying to do was create one page with dynamic content

#8 .josh

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

Posted 22 June 2006 - 06:02 AM

well my coding style is slightly different from yours. the point of my example was to look at how it's placed. the only thing i really see wrong with your actual code is $x is not the same as $_GET['x']; (unless your register globals are on, i think...) but in either case, you need to be using $_GET['x'] not $x, even if it does work.

also, this:

if($x == "")

is not the same as this:

if ($x)

the first one will include your home.php only if someone clicks on a link that has

index.php?x=

notice no value after it. it will not include home.php if they simply typed

index.php in the url, because your condition will only be true if x is set, and equal to "".



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 :)

#9 kriffer

kriffer
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 June 2006 - 06:11 AM

i see.. well the forums have done me good already... this line you type first time i put it in my code while you were replying and it works.. this line
<?php
      if ($_GET['x']) {
          include($_GET['x'] . '.php');
      } else {
          include('home.php');
      }
   ?>
worked.. thxnk alot i'll be back on tommorow




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users