hi guys iam a newbie. i like you guys to help me out on this...

i like to make a php page which takes content out of another php file. i know include does this, but i don't want to take the whole code, just parts of a page, for example one php file(x.php) has 10 tables. i am have 3 pages(eg. 1.php,2.php,3.php).

i want the 1.php page to get the first 3 tables from x.php,
2.php to get the next 3 tables

and so on and so forth.

i need this beacause my client needs to update his page's frequently and he does'nt know much of php or html, and i want him to edit only one page so that, it gets reflected in other pages.

thanx in advanceπŸ˜‰

muthukumar prakashamπŸ˜ƒ

    if 1.php will always get the first 3 tables from x.php why not try to set this tables to variables?

    /* content of x.php */
    
    $var1 = '<table id="1">
    .....
    </table>
    <table id="2">
    ....
    </table>
    <table id="3">
    ...
    </table>';
    
    $var2 = '<table id="4">
    .....';
    $var3 = '<table id="7">
    ....';
    
    /* then in 1.php do: */
    include("x.php");
    echo $var1;
    

      hi morital thanx for the reply, but its not working

      this the code i used

      x.php

      <html><body>

      <?
      var1='<table id="1"><tr><td>first table</tr></td></table>';
      <br>
      <br>
      var2='<table id="2"><tr><td>Second table</tr></td></table>';
      <br>
      <br>
      </body></html>

      1.php

      <html>
      <head>Testing</head>

      <body>

      <?
      include('x.php');
      echo $var1;
      ?>

      <p>&nbsp;</p>
      <hr>
      <p>&nbsp;</p>
      <?
      include('x.php');
      echo $var2;
      ?>

      </p>
      </body>
      </html>

      but iam getting a blank page for 1.php.

      whats wrong with the code??

      thanx in advance

        You have an error in your code:

        /* your code is here */
        <?
        var1='<table id="1"><tr><td>first table</tr></td></table>';
        <br>
        <br>
        var2='<table id="2"><tr><td>Second table</tr></td></table>';
        <br>
        <br>
        </body></html> 
        ........
        /* shuld be */
        <?
        $var1='<table id="1"><tr><td>first table</tr></td></table><br><br>';
        /* <br> is a HTML tag and PHP is tring to parse it and you get an error */
        $var2='<table id="2"><tr><td>Second table</tr></td></table><br><br>';
        </body></html>
        
        /* other way is to quit from php and return in HTML */
        <?
        $var1='<table id="1"><tr><td>first table</tr></td></table>'; ?>
        <br>
        <br>
        <?
        $var2='<table id="2"><tr><td>Second table</tr></td></table>'; ?>
        <br>
        <br>
        </body></html> 
        

        And you dont need to do include("x.php"); every time you have to use variable from x.php in 1.php, just do it once in the begining of 1.php or just before calling
        echo $var;

          hi morital, i tried what u said, no luckπŸ™ , i have copy pasted the scripts here. you can take a look at 1.php here

          http://rhytha.com/clients/maha1/1.php

          x.php

          <?

          var1='<table id ="1"><tr><td>first table</tr></td></table><br><br>';
          var2='<table id="2"><tr><td>Second table</tr></td></table>';

          ?>


          1.php

          <html>
          <head>
          <? include('x.php'); ?>
          </head>
          Testing
          <p>&nbsp;</p>
          <p>

          <?

          echo $var1;
          ?>

          </p><hr><hr><hr><hr><hr><hr><p>

          <?
          echo $var2;
          ?>

          </p>
          </body>
          </html>

            Hi

            Just looking at your last post, if what is in your x.php file is as you wrote, you missed the $ string sign at the front of the vars, should be:

            x.php

            <?

            $var1='<table id =\"1\"><tr><td>first table</tr></td></table><br><br>';
            $var2='<table id=\"2\"><tr><td>Second table</tr></td></table>';

            ?>


            ALSO. Note the slashes in front of double quotes. Without these PHP sees your code like this

            x.php

            <?

            var1='<table id ="
            / above line has error no end of line ; /
            1"><tr><td>first table</tr></td></table><br><br>';
            /above line has no operation/function /
            var2='<table id="
            / above line has error no end of line ; /
            2"><tr><td>Second table</tr></td></table>';
            /above line has no operation/function /

            ?>


            Well, you get the idea!

            Trevor
            PS, what editor do you use. A decent one would highlight these errors for you. I use AceHTML pro and it puts the error in pink!

              hi rhytha, here is your code in 2 files: 1.php and tables.php. i insert a little form in 1.php so u can choose from this file wich table from tables.php to load. if u change any of the file names dont forget to change those in the script source also.

              if my server is on u can test it at:
              http://morital.no-ip.info/public/rhytha/1.php

              here is the zip:

                thanx a lot morital, it works fine now. i had downloaded the code and went thru it, and the probelm is as trveor said, i did'nt put $ before var's.

                thanx a lot moritalπŸ˜ƒ πŸ˜ƒ πŸ˜ƒ

                trevor i use DW. it did'nt hightlight any error's.

                thanx trevor for you help as wellπŸ†’ πŸ†’

                  Write a Reply...