PHP-fil delt op i flere - hvordan???
Jeg har følgende kode til et nyhedssys hvor jeg godt kunne tænke mig at dele det op, sådan at min main.php viser de første 5 nyheder fra /home/nyheder/index.php.Selve nyheden bliver vist via /home/nyheder/index.php?newsid=
Og nyhedsarkivet bliver vist i /home/nyheder/arkiv.php
Jeg ville blive lykkelig vis nogle kunne hjælpe...
Her er sovsen:
<?
function pheed($newsid){
GLOBAL $PHP_SELF,$prev,$newsid,$month,$year;
include "newsadmin/nyheder.ini";
$conid=dbconnect ($dbname,$username,$password);
?>
<table width="500" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" align="center">
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td bgcolor="#043FC8">
<div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF">####</font></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#000075" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="3" height="100%">
<tr>
<td valign="top">
<?
if (!isset($newsid)){
if (!isset($prev)){
if (isset($month)){
$sql="SELECT id,date,title FROM $dbtable WHERE (MONTH(date)=$month AND YEAR(date)=$year) ORDER BY date DESC";
}else{
$sql="SELECT id,date,title FROM $dbtable ORDER BY date DESC LIMIT 8";
};
$result=dbquery($conid,$sql);
while (list($id,$date,$title)=dbfetch($result)){
$date=substr($date,0,10);
$dat=explode("-",$date);
$date="$dat[2]-$dat[1]-$dat[0]";
?>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="CCDDFF">
<? print $date ?>
<b>: </b></font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<b><a href="<? print $PHP_SELF ?>?newsid=<? print $id ?>">
<? print $title ?>
</a></b></font><br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<?
};
print "<p align=bottom><a href=$PHP_SELF?prev=all><b>« Nyhedsarkiv</b></a></p>";
} else{
?>
</font> <b> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<p align="center">
<? print Nyhedsarkivet ?>
</p>
</font></b> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<p align="center">
<?
$result = dbquery($conid, "SELECT DISTINCT(MONTH(date)) as month, year(date) as year FROM $dbtable ORDER BY year DESC, month DESC");
while (list($month,$year)=dbfetch($result)){
print "[ <font size=1><a href=\"$PHP_SELF?month=$month&year=$year\">$mtext[$month] $year</a></font> ] ";
};
print "</div>";
};
} else {
$result = dbquery($conid, "SELECT date,title,text,image,caption,URL,urlname FROM $dbtable WHERE (id='$newsid')");
list($date,$title,$text,$image,$caption,$URL,$urlname)=dbfetch($result);
$result = dbquery($conid, "UPDATE $dbtable SET view=view+1 WHERE (id='$newsid')");
$date=substr($date,0,16);
$dat1=explode(" ",$date);
$dat=explode("-",$dat1[0]);
$date="$dat[2]-$dat[1]-$dat[0]</b> <b>$dat1[1]";
?>
</p>
</font>
<p>
<?
$result = dbquery($conid, "SELECT max(id) as maxid FROM $dbtable WHERE (id<'$newsid') LIMIT 1 ");
list($tmp)=dbfetch($result);
if ($tmp!=""){
?>
<?
};
$result = dbquery($conid, "SELECT min(id) as minid FROM $dbtable WHERE (id>'$newsid') LIMIT 1 ");
list($tmp)=dbfetch($result);
if ($tmp!=""){
?>
<?
};
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="FF0000">
Opdateret d.
<? print $date ?>
</font></b></td>
</tr>
</table>
<font face="Verdana, Arial, Helvetica, sans-serif" size="5" color="CCDDFF">
</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="5" color="CCDDFF"><b>
<? print $title ?>
</b> </font><br>
<br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<?print $text;
if ($image!=""){
print "<center><img src=\"$photourl"."$newsid\" border=\"1\" $image>";
print "<br>$caption</center>";
};
if ($URL!=""){
print "<p align=left><a href=\"http://$URL\">$urlname</a></p>";
};
?>
</font>
<p><a href="printitem.php?newsid=<? print $newsid ?>" target="_blank"><img src="grafik/icon_print.gif" border="0" alt="Printervenlig version" width="22" height="20"></a>
<?
$result = dbquery($conid, "SELECT id,date,title FROM $dbtable WHERE id<$newsid ORDER BY date DESC LIMIT 5");
while (list ($newsid,$date,$title)=dbfetch($result)){
$date=substr($date,0,10);
?>
<?
};
};
dbfree($result);
?>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
}
pheed ($newsid);
?>