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>");
Inserting PHP code into existing PHP
Moderator: General Moderators
-
Bennettman
- Forum Contributor
- Posts: 130
- Joined: Sat Jun 15, 2002 3:58 pm
-
Bennettman
- Forum Contributor
- Posts: 130
- Joined: Sat Jun 15, 2002 3:58 pm
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Unsolicited but... If you want to take some of the effort out of typing your code by getting rid of all those parenthesis and a lot of quotes:
fanfic_code.php contents
Mac
Code: Select all
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
?>Code: Select all
<?php
echo <<<END
<tr>
<td rowspan="3" bgcolor="#E3E7E3" width="40" align="center">
<img src="http://dynamic3.gamespy.com/~soaworld/iB_html/non-cgi/Skin/Default/images/on.gif" />
</td>
<td colspan="3" bgcolor="#E3E7E3">
<a href="story.php?fic=$fic;page=1;totalpage=$totalpage">$name</a>
</td>
</tr>
<tr>
<td bgcolor="#E3E7E3">Author: $author</td>
<td bgcolor="#E3E7E3">Genre: $genre</td>
<td bgcolor="#E3E7E3">Pages:
END;
for ($link = 1; $link <= $totalpage; $link++) {
echo <<<END
<a href="story.php?fic=$fic;page=$link;totalpage=$totalpage">$link</a>
END;
}
echo <<<END
</td>
</tr>
<tr>
<td colspan="3" bgcolor="#E3E7E3">Description: $description</td>
</tr>
END;
?>