+ Reply to Thread
Results 1 to 4 of 4

Thread: help-add content to all pages at once

  1. #1
    andhrafun is offline x10Hosting Member andhrafun is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    3

    help-add content to all pages at once

    sir, i have made nearly some 200 html pages and uploaded them.i want to add some common text to all the pages instead of editing each and every page which will take very much time . for example ,i want to add the below one :
    "welcome everybody, this is my new site , i am bhaskar "
    can i add the above line to all of my pages in a folder at once , PLEASE HELP ME REGARDING THIS ...
    also....i forgot to add keywords to all the pages ....please tell me how to add the keywords to all pages ...
    also please tell me whether the STAFF of this website will be replying or not ....
    THANKING YOU .....

  2. #2
    taekwondokid42 is offline x10 Lieutenant taekwondokid42 is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    268

    Re: help-add content to all pages at once

    This is a php script, but php and html go together really well.

    http://www.tizag.com/phpT/include.php

    If that is somewhat confusing, you can start at the introduction of php and keep going until you get to this point.

    I find tizag a great tutorial overall, so you can use that for anything you might have questions about.

  3. #3
    Pingy's Avatar
    Pingy is offline x10Hosting Member Pingy is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    46

    Re: help-add content to all pages at once

    I believe I can be of some assistance here. Now, I'm taking this as a need to include the same text on almost 200 HTML pages without going in and doing it by hand. Much like taekwondokid42 suggested, this is where we cue PHP.

    In a new file ('mass_edit.php' -- just a suggestion for the name, though):
    PHP Code:
    <?
    $directory 
    'data'// THE NAME OF THE FOLDER THAT CONTAINS ALL OF THOSE PAGES GOES HERE
    $dir_hand opendir($directory); // CREATE DIRECTORY HANDLE
    while (($file readdir($dir_hand)) !== false// LOOP THROUGH ALL FILES
     
    {
    $ext substr($filestrpos($file'.') + 1strlen($file) - strpos($file'.') - 1); // DETERMINE EXTENSION
    $valid_ext = array('php''html''shtml''htm'); // DECLARE EXTENSIONS THAT SHOULD BE MODIFIED
    if (in_array($ext$valid_ext)) // TEST IF EXTENSION IS VALID
     
    {
    $old_data file_get_contents($directory '/' $file); // OLD DATA OF THE FILE
    $file_hand fopen($directory '/' $file'w'); // CREATE FILE HANDLE
    fwrite($file_handfile_get_contents('to_include.php') . $old_data); // PLACE CONTENTS OF "to_include.php" AT THE BEGINNING
     
    }
     }
    ?>
    Then, just throw the HTML that you'd like to be placed at the beginning of each page in a new file called to_include.php and run mass_edit.php. Remember, though, that this script is going to take all of the contents of that file and throw it at the very beginning of every single valid (extension-wise) file in the folder you specify.

    Because I don't know how your HTML pages are structured, I couldn't do anything else with this. If, however, you'd like to send me the source code of one of those pages, I can modify this so that it better suits your needs. Hope I've helped...
    Last edited by Pingy; 09-16-2007 at 01:06 PM.

  4. #4
    andhrafun is offline x10Hosting Member andhrafun is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    3

    Re: help-add content to all pages at once

    thanks for the help, after completing my work, i will give the source code

+ Reply to Thread

Similar Threads

  1. how can i convert Php pages and code into asp pages and code
    By n4tec in forum Scripts & 3rd Party Apps
    Replies: 11
    Last Post: 01-10-2009, 10:40 PM
  2. Ad-Code in PHP Pages
    By ghettoc401 in forum Free Hosting
    Replies: 3
    Last Post: 08-16-2007, 06:19 PM
  3. Ads on my pages
    By cokacola650 in forum Free Hosting
    Replies: 2
    Last Post: 02-16-2006, 11:38 AM
  4. Replies: 7
    Last Post: 09-16-2005, 11:27 AM
  5. [PHP] Placing the Ads in PHP Pages
    By Chris in forum Tutorials
    Replies: 22
    Last Post: 06-05-2005, 12:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers