Quantcast

Jump to content

» «
Photo

[PHP] Pages

No replies to this topic
Snow Racer
  • Snow Racer

    Member Title

  • Feroci
  • Joined: 23 Mar 2003
  • Norway

#1

Posted 01 May 2005 - 10:26 AM

I need help with news pages for this code

CODE
echo '<table border="1" width="'.$widthbrd.'" style="border-collapse: collapse" bordercolorlight="'.$colorbrd.'" bordercolordark="'.$colorbrd.'" bordercolor="'.$colorbrd.'">';
if ( $handle = opendir("data/") )
{
 while ( ( $file = readdir( $handle ) ) !== false )
 {
  if ( $file != "." && $file != ".." )
  {
   $news_array[] = $file;
  }
 }
 closedir( $handle );
}

array_multisort( $news_array, SORT_NUMERIC, SORT_DESC );

  switch ($_GET['news']) {
      case "archive":

array_splice( $news_array, $page, 10 );

      break;
      default:

array_splice( $news_array , $display);

}

$num_news = (count( $news_array));

foreach ( $news_array as $val )
{
 $news_file = file("data/$val");

 $date = $news_file[0];
 $title = $news_file[1];
 $author = $news_file[2];
 $text = $news_file[3];

 echo '<tr>
 <td bgcolor="'.$colorbg2.'">
<font face="Verdana" size="1" color="'.$color1.'">
<b>
<u>'.$title.'</u> - '.$date.'</b></td>
</tr>
<tr>
 <td bgcolor="'.$colorbg1.'">
 <p align="justify"><font face="Verdana" size="1" color="'.$color2.'">';
echo $text;
echo '</font></td><tr><td height="20"></td></tr>
</tr>';


}
echo '</table>';

Example:
I have 32 news...
on the first page I see 10 news (32,31,30,29,28,27,26,25,24,23)
and next page will show you next old 10 news (22,21,20,19,18,17,16,15,14,13)
and so on




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users