Jump to content

help.


Nightmare

Recommended Posts

Hi, I need help on Java Script. I got a free web hosting on 50webs.com. How do you make a menu for your website, appear on every unhidden web page you have for your web site? Cause when you are making a multi-page web site, and you want your menu on the left side of your screen, it is a pain and the butt to edit all 30 or so files to add one link. Here is a link to my menu, and the code for it. here is my menu.html code.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  <html><head>	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >	<link rel="stylesheet" type="text/css" href="sddm.css" mce_href="sddm.css" >	<title>JSwitch Slide Menu</title></head><body><div class="navbar"><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">General</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./index.htm">Home</a></div><div class="subItem"><a href="./soon.htm">Forums</a></div><div class="subItem"><a href="./soon.htm">Contact</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Christ Jesus</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./soon.htm">Quick Facts about Christ<br /> </a></div><div class="subItem"><a href="./soon.htm">Why was He here</a></div><div class="subItem"><a href="./soon.htm">First Coming</a></div><div class="subItem"><a href="./soon.htm">Second coming</a></div><div class="subItem"><a href="./soon.htm">How can I know Him</a></div><div class="subItem"><a href="./soon.htm">Is He really God in the flesh</a></div><div class="subItem"><a href="./soon.htm">Holy Spirit</a></div><div class="subItem"><a href="./soon.htm">Forgiveness</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">End Times</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Signs of the Last Days</a></div><div class="subItem"><a href="./soon.htm">Armageddon</a></div><div class="subItem"><a href="./soon.htm">The Rapture</a></div><div class="subItem"><a href="./soon.htm">Anti-Christ</a></div><div class="subItem"><a href="./soon.htm">Second Coming</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Sin</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">What is Sin</a></div><div class="subItem"><a href="./soon.htm">How to overcome Sin</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">The Bible</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Is it the Word of God</a></div><div class="subItem"><a href="./soon.htm">What one is the most accute</a></div><div class="subItem"><a href="./soon.htm">Bible version code</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><script src="xpmenuv21.js" type="text/javascript"></script></div><p> </p></body></html>

Link to comment
Share on other sites

You can't use Javascript to do that, you would need to either use a server-side language like PHP or ASP to include the menu file, or you could use server-side includes if they are enabled on the server, or you could put your list of links into a Javascript structure like an array that you can import on every page to build the menu dynamically.

Link to comment
Share on other sites

You can't use Javascript to do that, you would need to either use a server-side language like PHP or ASP to include the menu file, or you could use server-side includes if they are enabled on the server, or you could put your list of links into a Javascript structure like an array that you can import on every page to build the menu dynamically.
what does ASP stand for? I know that PHP is disable for people that have free web hosting.
Link to comment
Share on other sites

Including files is easy, but unfortunately one thing you are going to need to change is the filenames. Unless you can convince GoDaddy to modify your account to run .html files as PHP files (good luck with that), you will need to rename the files that you want to do the including to .php files. In practice, it will be best to just rename all of your .html files to .php files now, that way if you want to add more advanced PHP code to them later on you don't have to do another rename. So, that means you'll have to change all the links in your files also, but thankfully including the menu on every page will cut down on how many you have.Once you set your files up, just paste your menu code into a new file, and save that as a PHP file also. All you need in the file is the exact code you want to be included, you don't need any special PHP code or anything. Including a file in PHP is the exact same thing as if all that code was in the first PHP file, so you don't need anything special to be an "includable" file. You could name it whatever you want, you could name it .inc if you want, but it will be best for security to name it .php. Later on if you add any PHP code to your include file, naming it .php will make sure that if anyone looks at the include file in a browser they won't see your PHP code. If you look at a .inc file it will just display as normal text, and you will see all the code. So save your menu file as a .php file also.In the files where you want to do the including, all you need is an include statement. PHP is contained inside delimiters like this:<?php?>So any PHP code goes inside that. If you have this HTML:

<body>  <head>	...  </head>  <body>	<div id="menu">...</div>	<div id="content">...</div>  </body></html>

and if you put the entire menu div in an include file, you would do this on your other pages:

<body>  <head>	...  </head>  <body>	<?php include('path/to/menu.php'); ?>	<div id="content">...</div>  </body></html>

Link to comment
Share on other sites

so my menu.php file will look like

<body>  <head>	...  </head>  <body><div class="navbar"><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">General</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./index.htm">Home</a></div><div class="subItem"><a href="./soon.htm">Forums</a></div><div class="subItem"><a href="./soon.htm">Contact</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Christ Jesus</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./soon.htm">Quick Facts about Christ<br /></a></div><div class="subItem"><a href="./soon.htm">Why was He here</a></div><div class="subItem"><a href="./soon.htm">First Coming</a></div><div class="subItem"><a href="./soon.htm">Second coming</a></div><div class="subItem"><a href="./soon.htm">How can I know Him</a></div><div class="subItem"><a href="./soon.htm">Is He really God in the flesh</a></div><div class="subItem"><a href="./soon.htm">Holy Spirit</a></div><div class="subItem"><a href="./soon.htm">Forgiveness</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">End Times</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Signs of the Last Days</a></div><div class="subItem"><a href="./soon.htm">Armageddon</a></div><div class="subItem"><a href="./soon.htm">The Rapture</a></div><div class="subItem"><a href="./soon.htm">Anti-Christ</a></div><div class="subItem"><a href="./soon.htm">Second Coming</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Sin</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">What is Sin</a></div><div class="subItem"><a href="./soon.htm">How to overcome Sin</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">The Bible</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Is it the Word of God</a></div><div class="subItem"><a href="./soon.htm">What one is the most accute</a></div><div class="subItem"><a href="./soon.htm">Bible version code</a></div></div></div></div><!-- *********************************End Menu****************************** -->  </body></html>

Link to comment
Share on other sites

Don't put <html> or <body> tags in the include file unless you want those to appear in the final document. Like I said, the code in the include file will be inserted into the HTML code exactly as it is, you don't add anything extra. If you have <html> and <body> and <head> tags or whatever else in the include file, then those tags will show up wherever you put that include file, so if you include the file in the middle of your other page then those tags will show up in the middle of your document. Just copy the code that you want to include and paste it into a new file, don't change it or add anything to it unless you want that stuff to be included also. You're not making an HTML document here, you're saving some text that you want PHP to include on another page.

Link to comment
Share on other sites

so it is just

<php<div class="navbar"><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">General</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./index.htm">Home</a></div><div class="subItem"><a href="./soon.htm">Forums</a></div><div class="subItem"><a href="./soon.htm">Contact</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Christ Jesus</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./soon.htm">Quick Facts about Christ<br /></a></div><div class="subItem"><a href="./soon.htm">Why was He here</a></div><div class="subItem"><a href="./soon.htm">First Coming</a></div><div class="subItem"><a href="./soon.htm">Second coming</a></div><div class="subItem"><a href="./soon.htm">How can I know Him</a></div><div class="subItem"><a href="./soon.htm">Is He really God in the flesh</a></div><div class="subItem"><a href="./soon.htm">Holy Spirit</a></div><div class="subItem"><a href="./soon.htm">Forgiveness</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">End Times</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Signs of the Last Days</a></div><div class="subItem"><a href="./soon.htm">Armageddon</a></div><div class="subItem"><a href="./soon.htm">The Rapture</a></div><div class="subItem"><a href="./soon.htm">Anti-Christ</a></div><div class="subItem"><a href="./soon.htm">Second Coming</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Sin</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">What is Sin</a></div><div class="subItem"><a href="./soon.htm">How to overcome Sin</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">The Bible</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Is it the Word of God</a></div><div class="subItem"><a href="./soon.htm">What one is the most accute</a></div><div class="subItem"><a href="./soon.htm">Bible version code</a></div></div></div></div><!-- *********************************End Menu****************************** -->?>

Link to comment
Share on other sites

k, I just convert it into php,

<?phpecho "<div class=\"navbar\">\n";echo "<!-- *********************************Start Menu****************************** -->\n";echo "<div class=\"mainDiv\">\n";echo "<div class=\"topItem\">\n";echo "General\n";echo "\n";echo "</div>\n";echo "		\n";echo "<div class=\"dropMenu\">\n";echo "<!-- -->\n";echo "<div class=\"subMenu\" style=\"display: inline\">\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./index.htm\">Home</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Forums</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Contact</a>\n";echo "</div>\n";echo "\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "<!-- *********************************End Menu****************************** -->\n";echo "<br />\n";echo "<!-- *********************************Start Menu****************************** -->\n";echo "<div class=\"mainDiv\">\n";echo "<div class=\"topItem\">\n";echo "Christ Jesus\n";echo "</div>\n";echo "		\n";echo "<div class=\"dropMenu\">\n";echo "<!-- -->\n";echo "<div class=\"subMenu\" style=\"display: inline\">\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Quick Facts about Christ<br />\n";echo "\n";echo "</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Why was He here</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">First Coming</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Second coming</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">How can I know Him</a>\n";echo "\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Is He really God in the flesh</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Holy Spirit</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Forgiveness</a>\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "<!-- *********************************End Menu****************************** -->\n";echo "\n";echo "<br />\n";echo "<!-- *********************************Start Menu****************************** -->\n";echo "<div class=\"mainDiv\">\n";echo "<div class=\"topItem\">\n";echo "End Times\n";echo "</div>\n";echo "		\n";echo "<div class=\"dropMenu\">\n";echo "<!-- -->\n";echo "<div class=\"subMenu\" style=\"display: none\">\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Signs of the Last Days</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Armageddon</a>\n";echo "\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">The Rapture</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Anti-Christ</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Second Coming</a>\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "<!-- *********************************End Menu****************************** -->\n";echo "\n";echo "<br />\n";echo "<!-- *********************************Start Menu****************************** -->\n";echo "<div class=\"mainDiv\">\n";echo "<div class=\"topItem\">\n";echo "Sin\n";echo "</div>\n";echo "		\n";echo "<div class=\"dropMenu\">\n";echo "<!-- -->\n";echo "<div class=\"subMenu\" style=\"display: none\">\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">What is Sin</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">How to overcome Sin</a>\n";echo "\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "<!-- *********************************End Menu****************************** -->\n";echo "<br />\n";echo "<!-- *********************************Start Menu****************************** -->\n";echo "<div class=\"mainDiv\">\n";echo "<div class=\"topItem\">\n";echo "The Bible\n";echo "</div>\n";echo "		\n";echo "<div class=\"dropMenu\">\n";echo "<!-- -->\n";echo "<div class=\"subMenu\" style=\"display: none\">\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Is it the Word of God</a>\n";echo "\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">What one is the most accute</a>\n";echo "</div>\n";echo "<div class=\"subItem\">\n";echo "<a href=\"./soon.htm\">Bible version code</a>\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "</div>\n";echo "<!-- *********************************End Menu****************************** -->";?>

do I put that into the menu.php file?

Link to comment
Share on other sites

Geez, what did you do that for?Let's review.

All you need in the file is the exact code you want to be included, you don't need any special PHP code or anything.
you don't need anything special to be an "includable" file.
Just copy the code that you want to include and paste it into a new file, don't change it or add anything to it
If you start out with this, I'll refer to it as index.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  <html><head>	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >	<link rel="stylesheet" type="text/css" href="sddm.css" mce_href="sddm.css" >	<title>JSwitch Slide Menu</title></head><body><div class="navbar"><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">General</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./index.htm">Home</a></div><div class="subItem"><a href="./soon.htm">Forums</a></div><div class="subItem"><a href="./soon.htm">Contact</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Christ Jesus</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./soon.htm">Quick Facts about Christ<br /></a></div><div class="subItem"><a href="./soon.htm">Why was He here</a></div><div class="subItem"><a href="./soon.htm">First Coming</a></div><div class="subItem"><a href="./soon.htm">Second coming</a></div><div class="subItem"><a href="./soon.htm">How can I know Him</a></div><div class="subItem"><a href="./soon.htm">Is He really God in the flesh</a></div><div class="subItem"><a href="./soon.htm">Holy Spirit</a></div><div class="subItem"><a href="./soon.htm">Forgiveness</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">End Times</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Signs of the Last Days</a></div><div class="subItem"><a href="./soon.htm">Armageddon</a></div><div class="subItem"><a href="./soon.htm">The Rapture</a></div><div class="subItem"><a href="./soon.htm">Anti-Christ</a></div><div class="subItem"><a href="./soon.htm">Second Coming</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Sin</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">What is Sin</a></div><div class="subItem"><a href="./soon.htm">How to overcome Sin</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">The Bible</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Is it the Word of God</a></div><div class="subItem"><a href="./soon.htm">What one is the most accute</a></div><div class="subItem"><a href="./soon.htm">Bible version code</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><script src="xpmenuv21.js" type="text/javascript"></script></div><p> </p></body></html>

Then remove everything you want to duplicate and paste it exactly as it is in a new file, I'll call this menu.php:

<div class="navbar"><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">General</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./index.htm">Home</a></div><div class="subItem"><a href="./soon.htm">Forums</a></div><div class="subItem"><a href="./soon.htm">Contact</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Christ Jesus</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: inline"><div class="subItem"><a href="./soon.htm">Quick Facts about Christ<br /></a></div><div class="subItem"><a href="./soon.htm">Why was He here</a></div><div class="subItem"><a href="./soon.htm">First Coming</a></div><div class="subItem"><a href="./soon.htm">Second coming</a></div><div class="subItem"><a href="./soon.htm">How can I know Him</a></div><div class="subItem"><a href="./soon.htm">Is He really God in the flesh</a></div><div class="subItem"><a href="./soon.htm">Holy Spirit</a></div><div class="subItem"><a href="./soon.htm">Forgiveness</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">End Times</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Signs of the Last Days</a></div><div class="subItem"><a href="./soon.htm">Armageddon</a></div><div class="subItem"><a href="./soon.htm">The Rapture</a></div><div class="subItem"><a href="./soon.htm">Anti-Christ</a></div><div class="subItem"><a href="./soon.htm">Second Coming</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">Sin</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">What is Sin</a></div><div class="subItem"><a href="./soon.htm">How to overcome Sin</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><!-- *********************************Start Menu****************************** --><div class="mainDiv"><div class="topItem">The Bible</div>		<div class="dropMenu"><!-- --><div class="subMenu" style="display: none"><div class="subItem"><a href="./soon.htm">Is it the Word of God</a></div><div class="subItem"><a href="./soon.htm">What one is the most accute</a></div><div class="subItem"><a href="./soon.htm">Bible version code</a></div></div></div></div><!-- *********************************End Menu****************************** --><br /><script src="xpmenuv21.js" type="text/javascript"></script></div>

Now, back in index.html, remove everything you just pasted in the other file, replace it with an include statement, and save it as index.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >	<link rel="stylesheet" type="text/css" href="sddm.css" mce_href="sddm.css" >	<title>JSwitch Slide Menu</title></head><body><?php include 'menu.php'; ?><p> </p></body></html>

And that's it. You don't have to add any extra HTML tags to the file to be included, you don't add PHP tags because it's not PHP code, and you'll figure out really quickly that having PHP output an entire document using echo statements is a real pain in the ###### to maintain.Like I said, the include statement inserts the code exactly as-is, exactly as if the code were pasted over the include statement. Your example only has HTML code in it, your site doesn't have any PHP code. You could add PHP code into the include file if you wanted to use it to do something useful (other then to print static text), but it doesn't need to be PHP code.

Link to comment
Share on other sites

If you did that, it would work. The only piece of code getting executed is a PHP include statement, there's nothing fancy. I posted the menu.php file and the index.php file, save those, open index.php, and when you visit it in a browser you will see that it includes the menu.Keep in mind that in order to run PHP code, you need to view the file in a browser from a server that has PHP installed. You can't open a PHP file locally in your browser and run the PHP code, PHP requires a server to run. If you are testing this at home and don't want to install and set up a web server and the PHP software, then you will need to upload the files to your host in order to test them.

Link to comment
Share on other sites

okay, could this be a problem. in menu.php there is no images, but in .html there is images for the menu. but when I fully copy and/or convert the menu.html code into php and re-upload it as menu.php it shows the images. how ever if I just add html in the .php file without the <head> <title> etc tags it shows no images.

Link to comment
Share on other sites

Don't convert the menu file into PHP code :) it is pointless, standard HTML text will be included as well (you could even just link it to menu.html). Are you sure you*Have the correct path to the menu file in the include statement?*Named the file which the menu file is going to be included in with the .php extension (i.e. index.php)?*Put your images in the directory with index.php?*Remember, don't view menu.php (or menu.html), view index.php!Then it should work. What is happening at the moment? Are you seeing an error message? Are you seeing the include() statement in the browser? Is it just not doing anything?

Link to comment
Share on other sites

This is so simple that it's starting to get frustrating. Literally the only things to do if you want to have a certain block of HTML be dynamically included instead of static in the page are these steps:1. Open the existing file2. Copy the code you want to remove3. Replace the code you just copied with <?php include 'file.php'; ?>4. Create a new file5. Paste the code you just copied into the new file6. Save it with the same name that you used in the include statementThat's it. You don't type a single character (except the include statement), and you don't add or change anything about the code that you paste. You don't "convert it to PHP", or add PHP tags, or HTML tags, or echo statements, or whatever else. Copy, paste, save. That's literally all there is to it. If you're doing anything more complex then that, then that's your problem. If you're not sure what the problem is, paste the code from all the files you're using.

Link to comment
Share on other sites

k, all the text and the information is before </html> and </body> but it still doing the same thing.also on ./christ/jesus.php I get this warning

Warning: main(menu.php): failed to open stream: No such file or directory in /home/content/d/a/y/daymare/html/christ/jesus.php on line 3Warning: main(menu.php): failed to open stream: No such file or directory in /home/content/d/a/y/daymare/html/christ/jesus.php on line 3Warning: main(): Failed opening 'menu.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/d/a/y/daymare/html/christ/jesus.php on line 3

Link to comment
Share on other sites

You need to point it to the right file. You will need to enter the right path on other files to include the menu. If the menu is in the parent directory from the script you want to include it on, the path would be ../menu.php.For the layout problems, that doesn't have anything to do with the include, that is just a normal HTML layout issue. You'll need to get the HTML laid out how you want it to look, then figure out which parts of your standard structure you can move to the include file.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...