Jump to content

I am so confused please help me.


Holsey

Recommended Posts

Hello, i am fairly new to php and i'm working on my site, I'm installing a new poster to my site but I'm trying to install it into a template... this is the entire php script (except the admin.php part)

<?php

 

function getNewsList(){

 

  $fileList = array();

 

 

if ($handle = opendir("news")) {

// Read all file from the actual directory

while ($file = readdir($handle))  {

    if (!is_dir($file)) {

      $fileList[] = $file;

      }

}

}

 

rsort($fileList);

 

return $fileList;

}

 

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">

<html>

<body>

  <div id="main">

    <

    <table width="100%">

    <?php

   

      $list = getNewsList();

      foreach ($list as $value) {

      $newsData = file("news/".$value);

      $newsTitle  = $newsData[0];

        $submitDate = $newsData[1];

        unset ($newsData['0']);

        unset ($newsData['1']);

     

        $newsContent = "";

        foreach ($newsData as $value) {

          $newsContent .= $value;

        }

     

      echo "<div class=\"title\">". $newstitle ."</div><div class=\"date\">" . $submitDate . "</div>";

      echo  "<div class=\"newsarea\">".$newsContent."</br></hr size='1'></div>";

      }

    ?>

    </table>

 

  </div>

</body> 

 

the first div: title is where the title goes on the template,however on the template it is just regular so i would have to edit index.php to update the news, and if i don't have much time i want to be able to just login to a admin.php page and change the news and have the template still looking good. The date div is where the date is and the news area is whre the news goes, then theres the $newscontent $newstitles and $submitdate all that jazz. and when i run the page i get an error that says:Parse error: syntax error, unexpected T_CLASS, expecting ',' or ';' in /thisiswheremywebsitepagesare/ on line 105. line 105 is: echo "<div class=\"newsarea\">".$newsContent."</br></hr size='1'></div>"; please tell me what to do, im so confused

Link to comment
Share on other sites

<?php

function getNewsList(){
   
   $fileList = array();
   
   
   if ($handle = opendir("news")) {
      // Read all file from the actual directory
      while ($file = readdir($handle))  {
          if (!is_dir($file)) {
             $fileList[] = $file;
         }
      }
   }   
   
   rsort($fileList);
   
   return $fileList;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<body>
  <div id="main">
    <
    <table width="100%">
    <?php
    
      $list = getNewsList();
      foreach ($list as $value) {
         $newsData = file("news/".$value);
         $newsTitle  = $newsData[0];
         $submitDate = $newsData[1];   
         unset ($newsData['0']);
         unset ($newsData['1']);
         
         $newsContent = "";
         foreach ($newsData as $value) {
              $newsContent .= $value;
         }
         
          echo "<div class=\"title\">". $newstitle ."</div><div class=\"date\">" . $submitDate . "</div>";
         echo  "<div class=\"newsarea\">".$newsContent."</br></hr size='1'></div>";
      }
    ?>
    </table>
   
  </div>
</body>   

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.