9 Replies - 937 Views - Last Post: 09 May 2013 - 01:43 PM

#1 DaiToBu  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 93
  • Joined: 17-March 12

one menu in multiple pages?

Posted 09 May 2013 - 11:38 AM

This may be some where in the forum or the webs, but I could not find the good tutorial for it. I want to be able to edit the left menu, and the menu on every page from the site will be the same. I guess you know what I am talking about. Anyway, I had follow some of the respond on the web by using PHP, so I attempt to install XAMPP, and got it work. The only problem left is I don't know how to implement it correctly in PHP, and HTML file. I am not sure what folder I am suppose to put it in the XAMPP folder either. Please someone help me out, or upload a sample page for me. Thank you very much.

Is This A Good Question/Topic? 0
  • +

Replies To: one menu in multiple pages?

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3517
  • View blog
  • Posts: 12,008
  • Joined: 12-December 12

Re: one menu in multiple pages?

Posted 09 May 2013 - 11:58 AM

You can use PHP include() to include the content of another file: the docs

In the xampp folder there is a folder named htdocs that you would store your website(s) in, but I'm sure the introductory documentation for XAMPP tells you all this.
Was This Post Helpful? 0
  • +
  • -

#3 DaiToBu  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 93
  • Joined: 17-March 12

Re: one menu in multiple pages?

Posted 09 May 2013 - 12:01 PM

View Postandrewsw, on 09 May 2013 - 11:58 AM, said:

You can use PHP include() to include the content of another file: the docs

In the xampp folder there is a folder named htdocs that you would store your website(s) in, but I'm sure the introductory documentation for XAMPP tells you all this.


Haha, I was reading the exact page before your post. Let me play around with it, then I'll ask some more if need. Thank you andrewsw
Was This Post Helpful? 0
  • +
  • -

#4 DaiToBu  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 93
  • Joined: 17-March 12

Re: one menu in multiple pages?

Posted 09 May 2013 - 12:21 PM

I wonder if I create an HTML page, and I include another HTML using php include function like this
index.html file

</div>
<?php 
include 'leftNav.html'; //I want add this little page on the left menu
?>

<div id="rightnav">
This is the right nav
</div>


leftNav.html
<div id="leftnav">This is the leftnav</div>

Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3517
  • View blog
  • Posts: 12,008
  • Joined: 12-December 12

Re: one menu in multiple pages?

Posted 09 May 2013 - 12:23 PM

Go for it!
Was This Post Helpful? 0
  • +
  • -

#6 DaiToBu  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 93
  • Joined: 17-March 12

Re: one menu in multiple pages?

Posted 09 May 2013 - 12:26 PM

View Postandrewsw, on 09 May 2013 - 12:23 PM, said:

Go for it!


Not work haha.
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3517
  • View blog
  • Posts: 12,008
  • Joined: 12-December 12

Re: one menu in multiple pages?

Posted 09 May 2013 - 12:46 PM

ha, ha your php pages should have extension .php (index.php) otherwise the php-script will be ignored. (There is a setting that would enable .html to be interpreted as .php, but I wouldn't use it personally.)

Oh, and please don't just say "not work" or similar in any future posts, it offers nothing to the person trying to help you.

This post has been edited by Dormilich: 10 May 2013 - 12:53 AM

Was This Post Helpful? 0
  • +
  • -

#8 DaiToBu  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 93
  • Joined: 17-March 12

Re: one menu in multiple pages?

Posted 09 May 2013 - 01:36 PM

Oh sorry. If I change the index.html to index.php, then where are the html code? go?

Is this how it suppose to be? I am sorry, I just don't understand the concept between php and html together.
<?php
<html>
<body>

<?php include 'header.php'; ?>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>

</body>
</html>
?>

This post has been edited by Dormilich: 10 May 2013 - 12:53 AM

Was This Post Helpful? 0
  • +
  • -

#9 DaiToBu  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 93
  • Joined: 17-March 12

Re: one menu in multiple pages?

Posted 09 May 2013 - 01:41 PM

I think I got it work out. I guess I have to play around with the CSS side more to make the page more colorful. It seem to be too blank. Here what I did if anyone have the same problem

index.php
<?php include("menu.php"); ?>
<p>This is my home page that uses a common menu to save me time when I add
new pages to my website!</p>
</body>
</html>



menu.php
<html>
<body>
<a href="http://www.example.com/index.php">Home</a> - 
<a href="http://www.example.com/about.php">About Us</a> - 
<a href="http://www.example.com/links.php">Links</a> - 
<a href="http://www.example.com/contact.php">Contact Us</a> <br />


Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,788
  • Joined: 12-June 08

Re: one menu in multiple pages?

Posted 09 May 2013 - 01:43 PM

Preferably anywhere you have the start and stop PHP tags would be for just php.. I mean sure you can echo out html code but that's pretty rough going.

It's like javascript - I can dump that anywhere and as long as it is enclosed I am good to go.


<html>
<body>
<?php
// php here
?>
<?php include 'header.php'; ?>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<?php
// php there
?>
</body>
</html>

<?php
// could put php here
?>


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1