...

View Full Version : How can I call another php snippet inside PHP code?



bruceleejr
06-17-2010, 09:56 PM
This code snippet is already inside the <?php ?> tags. I wanted to keep this seperatly as like a "display" file. Because I have multiple pages using the exact same thing and its a pain to keep going through and updating the exact same thing. I would like to just call this piece into PHP. Is there anyway I can do this?




echo "<center><table border=1 bgcolor=white >
<tr>
<th><h1>Username</h1>
<a href=playersudesc.php>desc</a>, <a href=playersuasc.php>asc</a>
</th>
<th bgcolor=#C0CFFA>
<img src=/images/xbc.png>
<br>
<a href=playersxbcdesc.php>desc</a>, <a href=playersxbcasc.php>asc</a>
</th>
<th bgcolor=#C9FFC2>
<img src=/images/xlink2.png>
<br>
<a href=playersxlkdesc.php>desc</a>, <a href=playersxlkasc.php>asc</a>
</th>
<th><h1>Team</h1>
<a href=playerstdesc.php>desc</a>, <a href=playerstasc.php>asc</a>
</th>
<th>
<h1>Console</h1>
<img src=/images/XBOX.png>
<br>
<a href=playerscdesc.php>desc</a>, <a href=playerscasc.php>asc</a>
</th>
<th><h1>Location</h1>
<img src=/images/globe.png>
<br>
<a href=playersldesc.php>desc</a>, <a href=playerslasc.php>asc</a>
</th>
<th><h1>Bandwidth</h1>
<img src=/images/bandwidth.png>
<br>
<a href=playersbdesc.php>desc</a>, <a href=playersbasc.php>asc</a>
</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['fid4'] . "</td>";
echo "<td bgcolor=#C0CFFA>" . $row['fid5'] . "</td>";
echo "<td bgcolor=#C9FFC2>" . $row['fid6'] . "</td>";
echo "<td>" . $row['fid9'] . "</td>";
echo "<td>" . $row['fid7'] . "</td>";
echo "<td>" . $row['fid1'] . "</td>";
echo "<td>" . $row['fid8'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);

Rowsdower!
06-17-2010, 10:07 PM
Yes, you are looking for the include() (http://php.net/manual/en/function.include.php) function.

bruceleejr
06-17-2010, 10:12 PM
Okay so I would create a new file called "display.php" and then wrap the current code around php tags, and do something like:



include("display.php");


Correct~???

Rowsdower!
06-17-2010, 10:16 PM
Okay so I would create a new file called "display.php" and then wrap the current code around php tags, and do something like:



include("display.php");


Correct~???

Precisely!

bruceleejr
06-17-2010, 10:35 PM
wooo hoo~!! WORKED PERFECTLY~!! thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum