Changeset 47 for news.php


Ignore:
Timestamp:
Aug 19, 2007, 4:58:14 PM (17 years ago)
Author:
george
Message:

Listování stránek u aktualit.
Zjednodušení generování hlavního menu do funkcí.
Doplnění položek konfigurace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • news.php

    r16 r47  
    66{
    77  global $Database;
    8   echo('<strong>Aktuality:</strong>');
    9   echo('<div style="NewsTable">');
     8  $ItemPerPage = 6;
     9  if(array_key_exists('Page', $_GET)) $Page = $Database->real_escape_string($_GET['Page']); else $Page = 0;
    1010  $Database->select_db('wow');
    11   $Result = $Database->query('SELECT news.*, user.User as username FROM news JOIN user ON user.ID=news.user WHERE 1 ORDER BY time DESC LIMIT 6');
    12   while($Row = $Result->fetch_array())
     11  $DbResult = $Database->query('SELECT COUNT(*) FROM news');
     12  $Total = $DbResult->fetch_array();
     13  $Total = $Total[0];
     14 
     15  $Result = '<strong>Aktuality:</strong>';
     16  $Result .= '<div style="NewsTable">';
     17  $DbResult = $Database->query('SELECT news.*, user.User as username FROM news JOIN user ON user.ID=news.user WHERE 1 ORDER BY time DESC LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage);
     18  while($Row = $DbResult->fetch_array())
    1319  {
    14     echo('<div class="NewsItem">');
     20    $Result .= '<div class="NewsItem">';
    1521    if($Row['long_text'] != '') $Row['title'] = '<a href="?new_id='.$Row['id'].'">'.$Row['title'].'</a>';
    16     echo('<div class="NewsItemTitle"><strong>'.$Row['title'].'</strong> ('.HumanDate($Row['time']).')</div>')
    17     echo($Row['short_text'].' ('.$Row['username'].')</div>');
     22    $Result .= '<div class="NewsItemTitle"><strong>'.$Row['title'].'</strong> ('.HumanDate($Row['time']).')</div>'
     23    $Result .= $Row['short_text'].' ('.$Row['username'].')</div>';
    1824  }
    19   echo('</div>');
     25  $Result .= '</div>';
     26  $Result .= PagesList('?Page=', $Page, $Total, $ItemPerPage);
     27  return($Result);
    2028}
    2129
Note: See TracChangeset for help on using the changeset viewer.