include('../../admin/config.php');
// Effettuo la connessione al database
$idconnessione = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name);
// PAGINAZIONE //
$adjacents = 3;
$query = "SELECT COUNT(*) as num FROM leondoro_news WHERE stato = 1 ORDER BY posizione ASC";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = "news.php"; //your file name (the name of this file)
$limit = 10; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
$pagination = "";
if($lastpage > 1)
{
$pagination .= "
";
//previous button
if ($page > 1)
$pagination.= "
";
else
$pagination.= "
";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "
\n";
}
// END PAGINAZIONE //
$query_limit = mysql_query("SELECT * FROM leondoro_news WHERE stato = 1 ORDER BY posizione ASC LIMIT $start, $limit");
if ( mysql_num_rows($query_limit) <= 0 ) {
print " Al momento non ci sono messaggi pubblicati