<?php include "sql_config.php"; $posts = mysql_query("select * from news"); $total_posts = mysql_num_rows($posts); { $return = null; $pages = ceil($total/$ if ($page+$links <= $pages) { $start = $page; } else { $start = $pages-($links-1); $finish = $pages; } if ($start < 0) { $start = 1; } for ($i=$start;$i<=$finish;$i++) { $return .= " <a href='?page=".$i."'>".$i."</a> "; } return $return; } if (!isset($page)) { $page = "1"; } echo print_links($total_posts,$page,"10","5"); $query = mysql_query("select * from news limit ".(($page-1)*10)."; while ($row=mysql_fetch_array($query)) { echo "<br><center>".$row['name']."</center><br>".$row['content']."<br>от: ".$row['data'].""; } mysql_close($db_name); ?>