Jump to content

HTML and Repeating contents


rassul

Recommended Posts

HTML can't do it, but if you learn some server-side scripting you can get it done. PHP is the most popular one, you can learn it here: http://w3schools.com/php/ Normally, rather than putting the footer into every page, in PHP you'll have one page template and put the content into it based on the URL. PHP uses the include() directive for that.

  • Like 1
Link to comment
Share on other sites

The problem with attempting a workaround with Javascript is that your site isn't going to work for people who navigate with Javascript disabled. It's also invisible to search engines and it slows down the loading of your page. If your server supports PHP, just put this in every page:

<?php include('footer.php'); ?>

If you want to test first on your computer, you can download WAMP to test your PHP pages.

Link to comment
Share on other sites

HTML can't do it, but if you learn some server-side scripting you can get it done. PHP is the most popular one, you can learn it here: http://w3schools.com/php/ Normally, rather than putting the footer into every page, in PHP you'll have one page template and put the content into it based on the URL. PHP uses the include() directive for that.
How would you do it using PHP?
Link to comment
Share on other sites

I just showed you in my previous post. Put this in each of your pages:

<?php include('footer.php'); ?>

Assuming the contents if your footer is in a file called "footer.php"

Link to comment
Share on other sites

The problem with attempting a workaround with Javascript is that your site isn't going to work for people who navigate with Javascript disabled. It's also invisible to search engines and it slows down the loading of your page. If your server supports PHP, just put this in every page:
<?php include('footer.php'); ?>

If you want to test first on your computer, you can download WAMP to test your PHP pages.

I am using wamp. Here is my footer.php:
<?php echo "<p>This is footer</p>";?>

and place

<?php include('footer.php'); ?>

where the footer should be, but does not work.

Link to comment
Share on other sites

I am using wamp. Here is my footer.php:
<?phpecho "<p>This is footer</p>";?>

and place

<?php include('footer.php'); ?>

where the footer should be, but does not work.

I am inserting
<?php include('footer.php'); ?>

in my index.html file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...