Inserting PHP code into existing PHP
Posted: Mon Jun 17, 2002 10:19 am
I'm working on a fanfic script, viewable at http://tisoft.subfactor.net/remote/fanfic.php. Currently the bottom fic (Story 1) is what I have working. The problem is, I want to make it so that (to avoid having to paste the same PHP code for every fic) the main part of the code (in fanfic_code.php) is inserted into the existing PHP code. However, when I try the include tag, it actually writes the code to the screen, creating the top story in the page. And since I'm a newbie to PHP, I don't know any command to put the code in. Anyone?
fanfic.php code
<?php
$name = ("The Pendant");
$fic = ("thependant");
$totalpage = 13;
$author = ("<a href=mailto:juneaskew@hotmail.com>Sique</a>");
$genre = ("Action/Adventure/Drama");
$description = ("Around the happenings of Sique. A new member has joined Vyse's crew. But there is something about the pendant she has.");
$link = 1;
Code to add the contents of fanfic_code.php
?>
fanfic_code.php contents
print ("<tr><td rowspan=3 bgcolor=#E3E7E3 width=40 align=center><img src=http://dynamic3.gamespy.com/~soaworld/i ... on.gif><td colspan=3 bgcolor=#E3E7E3> ");
print ("<a href=story.php?fic=");
print ("$fic");
print (";page=1;totalpage=");
print ("$totalpage");
print (">");
print ("$name");
print ("</a></td></tr><tr><td bgcolor=#E3E7E3> Author: ");
print ("$author");
print ("</td><td bgcolor=#E3E7E3> Genre: ");
print ("$genre");
print ("</td><td bgcolor=#E3E7E3> Pages: ");
while ($link <= $totalpage) {
print ("<a href=story.php?fic=");
print ("$fic");
print (";page=");
print ("$link");
print (";totalpage=");
print ("$totalpage");
print (">");
print ("$link");
print ("</a> ");
$link = $link + 1;
}
print ("</td></tr><tr><td colspan=3 bgcolor=#E3E7E3> Description: ");
print ("$description");
print ("</td></tr>");
fanfic.php code
<?php
$name = ("The Pendant");
$fic = ("thependant");
$totalpage = 13;
$author = ("<a href=mailto:juneaskew@hotmail.com>Sique</a>");
$genre = ("Action/Adventure/Drama");
$description = ("Around the happenings of Sique. A new member has joined Vyse's crew. But there is something about the pendant she has.");
$link = 1;
Code to add the contents of fanfic_code.php
?>
fanfic_code.php contents
print ("<tr><td rowspan=3 bgcolor=#E3E7E3 width=40 align=center><img src=http://dynamic3.gamespy.com/~soaworld/i ... on.gif><td colspan=3 bgcolor=#E3E7E3> ");
print ("<a href=story.php?fic=");
print ("$fic");
print (";page=1;totalpage=");
print ("$totalpage");
print (">");
print ("$name");
print ("</a></td></tr><tr><td bgcolor=#E3E7E3> Author: ");
print ("$author");
print ("</td><td bgcolor=#E3E7E3> Genre: ");
print ("$genre");
print ("</td><td bgcolor=#E3E7E3> Pages: ");
while ($link <= $totalpage) {
print ("<a href=story.php?fic=");
print ("$fic");
print (";page=");
print ("$link");
print (";totalpage=");
print ("$totalpage");
print (">");
print ("$link");
print ("</a> ");
$link = $link + 1;
}
print ("</td></tr><tr><td colspan=3 bgcolor=#E3E7E3> Description: ");
print ("$description");
print ("</td></tr>");