Имам код за странциране на категории. Когато има нова информациая в дадена категориа не излиза па 2стр.
Ето кода
Ето кода
Код:
<html>
<head>
<title>???????? ?? ??????</title>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1251">
</head>
<body>
</body>
</html>
<?php include('conf.php'); ?>
<?php
$category = 2;
if(isset($_GET['category']) and is_numeric($_GET['category'])) {
$category = intval($_GET['category']);
}
$result = mysql_query("SELECT ime, nowina, awtor,snimka FROM news WHERE type = '".$category."'")
or die("?? ???? ?? ??????? ????????");
if(mysql_num_rows($result) > 0) {
$the_limit = "1";
$the_query = "SELECT ime, nowina, awtor, snimka FROM news WHERE type = '".$category."'";
$listed = "";
$listed_end = "";
$page = trim($_GET['page']);
if(is_numeric($page)){
$page = $page * $the_limit;
if( (!$page) or ($page == "1") ){
$a = $page;
$b = $a + $the_limit;
} else {
$a = $page;
$b = $a + $the_limit;
}
} else {
$a = "0";
$b = $the_limit;
}
$query = $the_query." limit $a, $the_limit";
$result = mysql_query($query) or die (mysql_error());
$result_all = mysql_query($the_query) or die (mysql_error());
$num_all = mysql_num_rows($result_all);
while($red = mysql_fetch_array($result)){
$listed.= $red['nowina']."<br />".
$red['awtor']."<br />".
$red['ime']."<br /> пїЅпїЅпїЅпїЅпїЅпїЅ: <img src='$red[snimka]' /><br><br>";
}
$num_pages = ceil($num_all / $the_limit);
for($i=0;$i<$num_pages;$i++){
$name = $i;
$name++;
if($name != $num_pages){
$last = " | ";
} else {$last = ""; }
$pages.= "<a href=\"?page=".$i."\">".$name."</a>".$last;
}
echo $listed;
echo "<br /><br />";
echo $pages;
} else {
echo "пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ.";
}
?>