i referred a site which said that using the include() we can include code of another page into the current page

But i am not getting the output as they showed.

this is my code

<html>
 <head>
     <style type="text/CSS">
       body
         {
          background-color:#696565;
            font-style:italic;
         }
    h1
    {
     color: green;  
     text-decoration:underline;
     font-style:italic;
     text-shadow:2px 2px #FAF8CC;
    }
     </style>
  <title>
     home page
  </title>
 </head>
 
    <body>
 
      <h1>  <center>   Get to know something  </center> </h1>
    <?php
       include("include.php");
       echo "hello";
    ?>
    </body>    
</html>

and the code for include.php is

<html>

  <head>
  <style type="text/css">
   
   
   a:link
    {
      color:red;
       text-decoration:none;
      
       
    }

    a:visited
      {
         text-decoration:none;
        color:red;
      }
    a:hover
      {
        color:brown;
         text-decoration:underlined;
          background-color:#FF8247;
      }
  
  </style>
  </head>
   <body>
     <table border=1 cellspacing=0  align ="center" >
       <tr>
        <td><a href="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>home</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>
        <td><a href="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>about us</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>
        <td><a href="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>info</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>
        <td><a href="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>login</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>
       </tr>
     </table>  
   </body>

</html>

and what is got as output didnt contain the include.php file
can anyone help me please
thanks in advance

Recommended Answers

All 8 Replies

You should not include two html headers in the same page. Just include the table.
Is your main file a PHP file? What you get?

"You should not include two html headers in the same page. Just include the table."
i didnt get this point
i am having only one <html> start and end tags in my file

thanks for the reply
the main file is not having .php as extension
it is a html file
so its not giving the required output
thanks for helping me :)

Great :)
On the two headers, it seems to me that you have an html header on main page, and another one on include.php, that will output two headers.
Bye :)

oh
then is it that i should remove that html tag in the include file??

yep. just leave the table block into include.php

if the the main file is not PHP then you will need to to change it to a PHP file. you can't put a PHP code block in an HTML file end expect any results. And you only want the table in the include file like noted above, but that would not cause the issues you are having. IF you have not already change the main files extension. it may help in the future to make all your file's php.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.