5 Replies Latest reply on Apr 7, 2010 9:55 PM by DeonH

    Need help to include external file in php file

    DeonH Level 1

      Hi all and thanx so long for your help.

       

      My question concerns the link below.

       

      body.php has a Javascript inside that calls the file that corresponds with the day of the month. So, in body.php the script will call 7.php

      I need this script to be run on all my pages.

       

      Please check out the link below? I will appreciate it also if you can suggest something better.

       

      Regards,

      Deon

       

      http://www.josua.co.za/tekste/body.php

        • 1. Re: Need help to include external file in php file
          martcol Level 4

          Here's a tutorial on using PHP includes:

           

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

           

          It's quite simple really, no need for javascript.  You must remember to save your files with a .php extension and not .html and your server must be able to run PHP.

           

          If you build your page, exactly as you want it you more or less, cut out the common pieces that you think you can utilise in other pages.  This could be the header, navigation and footer for example.  You put one or all of those sections of your page into sperate files and save them as:

           

          footer.php

          navigation.php

          header.php

           

          Then where the code was in your page you use an include and reference the file you want to insert.

           

          <?php include("header.php"); ?>

           


          That should do you.

           

          Martin

          • 2. Re: Need help to include external file in php file
            DeonH Level 1

            Hi Martin.

             

            Thank you for the link & help.

             

            What I need to figure out, is to have the file that I include based on everyday's today's date.

             

            I will keep on searching. Thanx again.

             

            Deon

            • 3. Re: Need help to include external file in php file
              Nancy OShea Adobe Community Professional & MVP

              This is a bit clumsy IMO.  Tell me exactly why you need to redirect people to a different page each day?  Is it because you want to display a daily quotation or inspirational message? If yes, there are better ways of doing this without a redirect.

               

              Nancy O.
              Alt-Web Design & Publishing
              Web | Graphics | Print | Media  Specialists
              http://alt-web.com/
              http://twitter.com/altweb
              http://alt-web.blogspot.com

              • 4. Re: Need help to include external file in php file
                Nancy OShea Adobe Community Professional & MVP

                This page produces a new quotation for each day of the month.  All quotes are in an array.  No need for 31 web pages.  Just one page with 31 daily messages.

                 

                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                
                <title>Josua Mannebediening</title>
                
                <link href="../scripts/josua-css.css" rel="stylesheet" type="text/css" />
                <script type="text/javascript" src="../p7pm/p7popmenu.js"></script>
                <style type="text/css" media="screen">
                <!--
                @import url("../p7pm/p7pmh12.css");
                -->
                </style>
                <script type="text/javascript">
                // QUOTE OF THE DAY SCRIPT: Add 31 quotes or inspirational messages to the array below. Each day a new quote will be displayed on your page.
                
                var date    = new Date().getDate();
                var quote   = new Array();
                quote[1]   = "Quote no: 1";
                quote[2]   = "Quote no: 2";
                quote[3]   = "Quote no: 3";
                quote[4]   = "Quote no: 4";
                quote[5]   = "Quote no: 5"; 
                quote[6]   = "Quote no: 6";
                quote[7]   = "Quote no: 7";
                quote[8]   = "Quote no: 8";
                quote[9]   = "Quote no: 9";
                quote[10]  = "Quote no: 10";
                quote[11]  = "Quote no: 11";
                quote[12]  = "Quote no: 12";
                quote[13]  = "Quote no: 13";
                quote[14]  = "Quote no: 14";
                quote[15]  = "Quote no: 15";
                quote[16]  = "Quote no: 16";
                quote[17]  = "Quote no: 17";
                quote[18]  = "Quote no: 18";
                quote[19]  = "Quote no: 19";
                quote[20]  = "Quote no: 20";
                quote[21]  = "Quote no: 21";
                quote[22]  = "Quote no: 22";
                quote[23]  = "Quote no: 23";
                quote[24]  = "Quote no: 24";
                quote[25]  = "Quote no: 25";
                quote[26]  = "Quote no: 26";
                quote[27]  = "Quote no: 27";
                quote[28]  = "Quote no: 28";
                quote[29]  = "Quote no: 29";
                quote[30]  = "Quote no: 30";
                quote[31]  = "Quote no: 31";
                </script>
                </head>
                <body onload="P7_initPM(1,12,0,-20,10)">
                <div id="container">
                <!-- container begin -->
                <div id="header">
                <!-- header begin -->
                <!-- header eindig -->
                </div>
                
                <div id="navigation">    <!-- menu begin -->
                <ul id="p7PMnav">
                <li><a href="../index.php">Tuisblad</a></li>
                <li><a href="../wiesons.php">Wie is ons?</a></li>
                <li><a href="../waardes.php">Waardes</a></li>
                <li><a href="../getuienisse.php">Getuienisse</a></li>
                <li><a href="../kontak.php">Kontak ons</a></li>
                <!--[if lte IE 6]><style>#p7PMnav a{height:1em;}#p7PMnav li{height:1em;}#p7PMnav ul li{float:left;clear:both;width:100%}</style><![endif]-->
                <!--[if IE 6]><style>#p7PMnav ul li{clear:none;}</style><![endif]-->
                <!--[if IE 7]><style>#p7PMnav a{zoom:100%;}#p7PMnav ul li{float:left;clear:both;width:100%;}</style><![endif]-->
                </ul>
                <!-- menu eindig -->
                </div>
                
                <div id="content">
                <h1>Main page content here</h1>
                <p>This is where your regular page content goes. </p>
                </div>
                
                <div id="bits">
                <!-- bits begin -->
                <p><img src="../graphics/teksvers.png" alt="teksvers" width="229" height="25" /></p>
                <h2>Quote of the Day</h2>
                <hr />
                <script type="text/javascript">
                <!--
                document.write(quote[date]);
                //-->
                </script>
                
                <p><a href="http://www.facebook.com/group.php?gid=113605945319972"><img src="../graphics/facebook_pic.png" alt="FB" width="229" height="95" border="0" /></a></p>
                </div>  <!--end bits -->
                
                <div id="footer"> <!-- footer begin -->
                <p>Priester ... Profeet ... Koning in my huis</p>
                </div>  <!--end footer -->
                </div>  <!--end container -->
                </body>
                </html>
                
                

                 

                Nancy O.

                • 5. Re: Need help to include external file in php file
                  DeonH Level 1

                  Dear Nancy.

                   

                  Thank you very much for your help. This was exactly what I want.

                   

                  Regards,

                  Deon