Including Pieces of Code
Moderator: General Moderators
Including Pieces of Code
I want to include only a small portion of code. When I use include(), it puts the entire page I include and shows up. I only want to show a table from one page, on the new one. How would I do this?
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
-
Regicollis
- Forum Newbie
- Posts: 8
- Joined: Thu Nov 25, 2010 8:51 am
Re: Including Pieces of Code
The include command will include the entire file.
If you want to use the same table in multiple files you can put the table (And only the table) in a separate file and use the include command on all pages you want the table to be on. The "table.php" (or whatever name you want) file should look like this:
i.e. no other markup than the one creating the table.
Then you use on the pages where you would like your table to appear.
If you want to use the same table in multiple files you can put the table (And only the table) in a separate file and use the include command on all pages you want the table to be on. The "table.php" (or whatever name you want) file should look like this:
Code: Select all
<table>
<tr>
<td>This is where the content of the table goes</td>
</tr>
</table>
Then you use
Code: Select all
<?php include "table.php";?>