Changeset 456
- Timestamp:
- Mar 1, 2009, 2:59:06 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/beta/inc/html.php
r455 r456 222 222 $limit = 5; 223 223 mysql_query("SET NAMES 'utf8'"); 224 $result = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM articles $where ORDER BY date DESC LIMIT $limit OFFSET " . intval($_GET["offset"])); 225 $pocet = mysql_query(mysql_num_rows("SELECT date FROM `articles` $where "); 226 if ($pocet > 0) 224 225 $pocet = mysql_result(mysql_query("SELECT COUNT(*) FROM articles $where"), 0); 226 $offset = ($_GET["offset"] ? $_GET["offset"] : $pocet); 227 $result = mysql_query("SELECT * FROM articles $where ORDER BY date DESC, id DESC LIMIT $limit OFFSET " . ($pocet - $offset)); 228 if ($pocet != 0) 227 229 { 228 230 while($row = mysql_fetch_array($result)){ … … 269 271 "; 270 272 } 271 $pocet = mysql_result(mysql_query(" SELECT FOUND_ROWS()"), 0); 272 if ($_GET["offset"]) { 273 echo "<a href='$_SERVER[PHP_SELF]" . ($_GET["offset"] != $limit ? "?offset=" . ($_GET["offset"] - $limit) : "") . "'>zpět</a>\n"; 274 } 275 if ($pocet > $_GET["offset"] + $limit) { 276 echo "<a href='$_SERVER[PHP_SELF]?offset=" . ($_GET["offset"] + $limit) . "'>vpřed</a>\n"; 277 } 278 279 280 $result = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM articles $where ORDER BY date DESC $limit OFFSET " . ($limit * $_GET["strana"])); 281 $pocet = mysql_result(mysql_query(" SELECT FOUND_ROWS()"), 0); 282 if ($_GET["strana"]) { 283 echo "<a href='$_SERVER[PHP_SELF]" . ($_GET["strana"] != 1 ? "?strana=" . ($_GET["strana"] - 1) : "") . "'>zpět</a>\n"; 284 } 285 if ($pocet > $limit * ($_GET["strana"] + 1)) { 286 echo "<a href='$_SERVER[PHP_SELF]?strana=" . ($_GET["strana"] + 1) . "'>vpřed</a>\n"; 287 } 273 if ($offset < $pocet) { 274 echo "<a href='$_SERVER[PHP_SELF]" . ($offset + $limit < $pocet ? "?offset=" . ($offset + $limit) : "") . "'>zpět</a>\n"; 275 } 276 if ($offset > $limit) { 277 echo "<a href='$_SERVER[PHP_SELF]?offset=" . ($offset - $limit) . "'>vpřed</a>\n"; 278 } 279 280 281 282 288 283 289 284
Note:
See TracChangeset
for help on using the changeset viewer.