Changeset 583 for trunk/inc/html.php
- Timestamp:
- May 7, 2009, 9:15:17 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/html.php
r578 r583 195 195 public function ShowNews($kategorie) 196 196 { 197 include('inc/db.php'); 198 global $db_webu; 197 global $Config; 199 198 200 199 echo('<table class="NewsCategoryTable">'. … … 208 207 $this->QuickNew(); 209 208 210 if($kategorie == "all")211 { 212 $where = " ";213 } else 214 { 215 $where = "WHERE `category` = '".$kategorie."'";209 if($kategorie == 'all') 210 { 211 $where = ''; 212 } else 213 { 214 $where = 'WHERE `category` = "'.$kategorie.'"'; 216 215 } 217 216 218 mysql_connect($db_server, $db_user, $db_pass); 219 mysql_select_db($db_webu); 217 $this->db->select_db($Config['Database']['Database']); 220 218 $limit = 5; 221 219 222 $pocet = mysql_num_rows(mysql_query("SELECT id FROM `articles`".$where."ORDER BY `date` DESC;")); 223 $offset = (isset($_GET["offset"]) ? $_GET["offset"] : $pocet); 220 $DbResult = $this->db->query('SELECT id FROM `articles` '.$where.' ORDER BY `date` DESC;'); 221 $pocet = $DbResult->num_rows; 222 $offset = (isset($_GET['offset']) ? $_GET['offset'] : $pocet); 224 223 225 224 if($pocet != 0) 226 225 { 227 mysql_query('SET NAMES utf8'); 228 $result = mysql_query("SELECT * FROM articles $where ORDER BY date DESC, id DESC LIMIT $limit OFFSET " . ($pocet - $offset)); 229 while($row = mysql_fetch_array($result)) 226 $result = $this->db->query('SELECT * FROM articles '.$where.' ORDER BY date DESC, id DESC LIMIT '.$limit.' OFFSET '.($pocet - $offset)); 227 while($row = $result->fetch_array()) 230 228 { 231 229 $row['text'] = str_replace('<br>', '<br />', $row['text']); 232 switch ($row["category"])230 switch($row['category']) 233 231 { 234 232 case 1: 235 $cat = "Server novinky";236 $link = "servernews";233 $cat = 'Server novinky'; 234 $link = 'servernews'; 237 235 break; 238 236 case 2: 239 $cat = "GM novinky";240 $link = "gmnews";237 $cat = 'GM novinky'; 238 $link = 'gmnews'; 241 239 break; 242 240 case 3: 243 $cat = "In-game novinky";244 $link = "gamenews";241 $cat = 'In-game novinky'; 242 $link = 'gamenews'; 245 243 break; 246 244 case 4: 247 $cat = "Články";248 $link = "articles";245 $cat = 'Články'; 246 $link = 'articles'; 249 247 break; 250 248 } … … 252 250 $date = explode('-', $date_arr[0]); 253 251 $time = mktime(0, 0, 0, $date[1], $date[2], $date[0]); 254 $human_date = date ("d.m.Y", $time);252 $human_date = date('d.m.Y', $time); 255 253 echo('<table class="NewsQuickInfoTable">'. 256 254 '<tr>'. 257 '<td><strong>'.$row[ "title"].'</strong></td>'.255 '<td><strong>'.$row['title'].'</strong></td>'. 258 256 '<td style="width: 100px">'.$human_date.'</td>'. 259 257 '</tr>'. 260 258 '<tr>'. 261 '<td colspan="2">'.$row[ "text"].'</td>'.259 '<td colspan="2">'.$row['text'].'</td>'. 262 260 '</tr>'. 263 261 '<tr>'. … … 271 269 if($offset < $pocet) 272 270 { 273 echo( "<a href='$_SERVER[PHP_SELF]" . ($offset + $limit < $pocet ? "?offset=" . ($offset + $limit) : "") . "'><-- novější</a>\n ");271 echo('<a href="'.$_SERVER['PHP_SELF'].($offset + $limit < $pocet ? '?offset='.($offset + $limit) : '').'"><-- novější</a>\n '); 274 272 } 275 273 if($offset > $limit)
Note:
See TracChangeset
for help on using the changeset viewer.