Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Simple PHP News System Problems
wutske
post Jul 13 2006, 12:41 PM
Post #1


Way Out Of Control - You need a life :)
Group Icon

Group: [HOSTED]
Posts: 1,043
Joined: 2-August 05
From: Kapellen (Antwerp, Belgium)
Member No.: 7,585



For the new version of my website I'm trying to make a very simple newssytem based on php.

Each newsitem will get it's own html page, something like this:
CODE

<html>
<head>
<title>Welkom</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>

<p>HERE COMES THE TXT</p>

</body>
</html>


All other data will be stored in a file called news.inc

CODE

<?php
$news = array();
$news[] = '110706_jovolka.html';
$news[] = '110706_lorum.html';
$news[] = '090706_welkom.html';

$title = array();
$title[] = 'Over JoVolKa';
$title[] = 'Lorum Ipsum';
$title[] = 'Welkom';

$date = array();
$date[] = '11/07/06';
$date[] = '11/07/06';
$date[] = '09/07/06';
?>


And the main news page is something like this:
CODE

<html>
<head>
<title>JoVolKa Unofficial News</head>
<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
<?php
include ("news.inc");
$iVariabele = 0;
foreach( $news as $id => $file )
{
  if ($iVariabele < 8)
        {
             echo '<div class="title"><table width="100%"><tr class="title"><td class="title">';
             echo $title[$id];
             echo '</td><td class="date">';
             echo $date[$id];
             echo '</td></tr></table></div><div class="news">';
             include ("$news[$id]");
             echo '</div>';    
             $iVariabele++;
         }
}

?>  

</body>
</html>





Now, the problem is that it does show the first newsitem (0 in the array) completely wrong. It does not show the title, date, but only the news, but it also ignores the lay-out, only for that first item, the rest is okay.

I've been doing some test:

CODE

<html>
<head>
<title>JoVolKa Unofficial News</head>
</head>
<body>
<?php
include "news.inc";
print_r($news);
echo '  Date 0 = ' . $date[0] . '  Title 0 = ' . $title[0] . '  File 0 = ' . $news[0];
?>
</body>
</html>


results in:

Array ( [0] => 110706_jovolka.html [1] => 110706_lorum.html [2] => 090706_welkom.html ) Date 0 = 11/07/06 Title 0 = Over JoVolKa File 0 = 110706_jovolka.html

When I change that to

CODE

<html>
<head>
<title>JoVolKa Unofficial News</head>
</head>
<body>
<?php
include "news.inc";
print_r($news);
echo '  Date 0 = ' . $date[0] . '  Title 0 = ' . $title[0] . '  File 0 = ' . $news[0];

             echo '<div class="title"><table width="100%"><tr class="title"><td class="title">';
             echo $title[0];
             echo '</td><td class="date">';
             echo $date[0];
             echo '</td></tr></table></div><div class="news">';
             include ("$news[0]");
             echo '</div>';
?>        
    
</body>
</html>


then it in fact only does the include thing.

Who can help me ???
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jul 14 2006, 09:43 AM
Post #2


Super Member
Group Icon

Group: [HOSTED]
Posts: 760
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



QUOTE(wutske @ Jul 13 2006, 07:41 AM) *

For the new version of my website I'm trying to make a very simple newssytem based on php.

Each newsitem will get it's own html page, something like this:
CODE

<html>
<head>
<title>Welkom</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>

<p>HERE COMES THE TXT</p>

</body>
</html>


All other data will be stored in a file called news.inc

CODE

<?php
$news = array();
$news[] = '110706_jovolka.html';
$news[] = '110706_lorum.html';
$news[] = '090706_welkom.html';

$title = array();
$title[] = 'Over JoVolKa';
$title[] = 'Lorum Ipsum';
$title[] = 'Welkom';

$date = array();
$date[] = '11/07/06';
$date[] = '11/07/06';
$date[] = '09/07/06';
?>


And the main news page is something like this:
CODE

<html>
<head>
<title>JoVolKa Unofficial News</head>
<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
<?php
include ("news.inc");
$iVariabele = 0;
foreach( $news as $id => $file )
{
  if ($iVariabele < 8)
        {
             echo '<div class="title"><table width="100%"><tr class="title"><td class="title">';
             echo $title[$id];
             echo '</td><td class="date">';
             echo $date[$id];
             echo '</td></tr></table></div><div class="news">';
             include ("$news[$id]");
             echo '</div>';    
             $iVariabele++;
         }
}

?>  

</body>
</html>

.
.
.
then it in fact only does the include thing.

Who can help me ???

Hi there, your problem is caused by the title tag in your main news page, simply replace with </title> your close tag.
CODE

<html>
<head>
<title>JoVolKa Unofficial News</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
.
.
.


Best regards,
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Need Help Is Adding A PHP Based News Module To My Site(2)
  2. Some Problems Sometimes On Other Sites!(2)
  3. PHP Script: Separating News Into Pages(2)
  4. Problem With PHP Scripts Without MySQL(1)
  5. User Authentication Session Handling Problems(14)
  6. Rss/atom Feed For Php(5)
  7. Making My Album(3)
  8. Htaccess/gd Problems.(0)
  9. I'm Having Problems With Sessions(2)
  10. Five Common Php Database Problems(0)


 



- Lo-Fi Version Time is now: 7th October 2008 - 06:01 AM