si hai ragione ho scritto $pagina invece di $num_page,incolla il codice in questo modo e metti un echo per verificare gli articoli presenti nel database:
echo $num_articoli_totali;
ecco il codice:
Codice PHP:
<?php
require_once('config.php');
$art_per_pag = 8;
$start=0;
if (!isset($_GET['pag']) or ($_GET'pag']==1)){
$sql = " SELECT * FROM pagine ORDER by id DESC LIMIT $start, $art_per_pag";
}else{
$start = $art_per_pag * ($_GET[pag]-1);
$sql =" SELECT * FROM pagine ORDER by id DESC LIMIT $start, $art_per_pag";
}
$query = mysql_query($sql);
while($row = mysql_fetch_array($query))
{
$html = "<div id='box'>";
$html .= "<div id='title'>";
$html .="<div id='testo'>";
$html .= "[b]$row[titolo][/b]";
$html .= "</div>";
$html .="<div id='prezzo'>";
$numero=$row['prezzo'];
$numm=number_format( $numero , 2 , "," , "." );
$html .= "[b]€ $numm[/b]";
$html .= "</div>";
$html .= "</div>";
$html .= "<div id='img'>";
$sql_img = "SELECT * FROM immagini WHERE paginaid=$row[id] AND copertina=1 LIMIT 1 ";
$query_img = mysql_query($sql_img);
$row_img = mysql_fetch_array($query_img);
$html .= "[img]foto/$row_img[immagine][/img]";
$html .= "</div>";
$html .= "<div id='art'>";
$testo = "$row[testo]";
$preview = substr($testo,0 , 310);
$html .= "$preview..." ."
";
$html .= "<div id='dettagli'>";
$html .= "[url='#']dettagli[/url]";
$html .= "</div>";
$html .= "</div>";
$html .= "</div>";
echo $html;
}
?>
<div style="position:relative;top:10px;padding:0;">
<?php
$num_page = (!isset($_GET[pag]) || empty($_GET[pag]) ? 1 : $_GET[pag]);
$perpage = 8;
$query="SELECT * FROM pagine ORDER BY id";
$res=mysql_query($query);
$num_articoli_totali=mysql_num_rows($res);
$next = $prev = false;
$pagine_tot=ceil($num_articoli_totali/$art_per_pag);
$link="";
if(($num_page==1)&&($num_articoli_totali<=8))
{
$link.="";
}
else{
if(($num_page!=1)&&($num_page<=$pagine_tot))
{
$pag=$num_page-1;
$link.="<a style=\"color:#BC040E;text-decoration:none\" href=articoli.php?pag=$pag>Prev</a>";
}
if(($num_page>0)&&($num_page<$this->$pagine_tot))
{
$pag=$num_page+1;
$link.="<a style=\"color:#BC040E;text-decoration:none\" href=articoli.php?pag=$pag>Next</a>";
}
}
echo $link;
?>