Advertisement
Guest User

News

a guest
Jun 20th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. <?php
  2. include('core.php');
  3. closed();
  4.  
  5. include(INC.'class/create.php');//Klasa do obsługi szablonów
  6. $template = new template;
  7.  
  8. if(!empty($_GET['id'])){
  9.     $id = (int)$_GET['id'];
  10.     $result = mysql_query("SELECT * FROM `news` WHERE `nid` = $id") or error();
  11.     if(mysql_num_rows($result) > 0){
  12.         $row = mysql_fetch_array($result);
  13.         //Dodawanie do zmiennych w szablonie różnych informacji
  14.         $template->nid = $row['nid'];
  15.         $template->title = $row['title'];
  16.         $template->photo = $row['photo'];
  17.         $template->date = $row['date'];
  18.         $template->moretext = $row['moretext'];
  19.         $template->reads = $row['reads'];
  20.         $template->visible = $row['visible'];
  21.         $template->pagetitle = 'News #'.$row['nid'];
  22.         $template->load('news_id.php'); //Ładowanie pliku który ma być wyświetlony
  23.     }
  24.     else{
  25.         $template->pagetitle = 'Nie istnieje taki news!';
  26.         $template->load('no_result.php');
  27.         $template->title = 'Nie istnieje taki news!';
  28.     }
  29. }
  30. else{
  31.     $query = "SELECT * FROM `news` order by `date` DESC";
  32.     $result = mysql_query($query) or error();
  33.     if(mysql_num_rows($result) > 0){
  34.         $content = '';
  35.         while($row = mysql_fetch_array($result))
  36.         {
  37.             $date = date('d/m/Y', strtotime($row['date']));
  38.             $content .= '<div class="article">
  39.                 <img src="'.NEWS_IMAGES_MINI_WWW.$row['photo'].'" alt="'.$row['nid'].'" />
  40.                 <h3>'.$row['title'].'</h3>
  41.                 <h4>'.$date.'</h4>
  42.                 '.$row['text'].'
  43.                 <div class="readmore"><a href="'.WWW.'news.php?id='.$row['nid'].'">Czytaj dalej</a></div>
  44.             </div>';
  45.         }
  46.         $template->load('news.php');
  47.         $template->pagetitle = 'News';
  48.         $template->news = $content;
  49.     }
  50.     else{
  51.         $template->pagetitle = 'News';
  52.         $template->load('news.php');
  53.         $template->news = '<center><h2>Brak newsów<h2/></center>';
  54.     }
  55. }
  56.  
  57.  
  58. $template->display(); //Wyświetlenie strony
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement