Salve a tutti ragazzi, il seguente codice permette di visualizzare tutti i film che sono presenti nel database, il problema e che quando clicco sulla pagina successiva mi visualizza sempre la stessa pagina. Da che cosa dipende ? Sarà che devo dichiarare la costante tot nella select ? E se si come fare ! Ecco il codice:
<?
include("config.PHP");
include("selezione.PHP");
$tot=0;
if (!isset($start) OR $start<0){
$start=0;
$step=20;
}
$query=mysql_query("SELECT * FROM `film` order by titolo asc LIMIT $start,$step ") OR DIE ("select Non Riuscita");
?>
<html>
<body>
<div align="center">
<font color="#000099" size="4" face="Arial, Helvetica, sans-serif">Elenco
Film </font></p>
</div>
<div align="center"></div>
<div align="center">
<table width="800" border="0" cellspacing="1" cellpadding="0">
<tr bordercolor="#FFFFFF" bgcolor="#000099">
<td width="6"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">numero</font></td>
<td width="200"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">nome</font></td>
<td width="50"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">genere</font></td>
<td width="220"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">attori</font></td>
</tr>
<?
while ($row=mysql_fetch_array($query))
{
echo "<tr bgcolor='#CCCCCC'>";
echo "<td width='6'> <font face='Arial, Helvetica, sans-serif' size='2' color='#000099'>$row[id]</font></td>";
echo "<td width='200'> <font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[titolo]</font></td>";
echo "<td width='50'><font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[genere]</font></td>";
echo "<td width='220'><font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[attore1],$row[attore2],$row[attore3]</font></td>";
echo"</tr>";
}
?>
</table>
</div>
<div align="center">
<table width=37% border=0 align="center">
<tr>
<td width=29% align=left>
<?
if ($start>0)
{
$start_back = $start - $step;
echo "<a href=visualizza.php?start=$start_back>precedenti</a>";
}
?>
<div align="right"></div></td>
<?
$query1=mysql_query("SELECT count(*) AS tot FROM film ");
$row=mysql_fetch_array($query1);
$pages=intval(($row["tot"]-1) / $step)+1;
?>
<td width=38% align=center>
<?
for ($i=0; $i<$pages AND $i<20; $i++)
{ $start_page = $i * $step;
echo "<a href=visualizza.php?start=$start_page>" . ($i+1) . "</a> ";
}
?>
</td>
<td width=33%>
<?
if ($start + $step < $row["tot"])
{ $start_next = $start + $step;
echo "<a href=visualizza.php?start=$start_next>successivi</a>";
}
?>
</td>
</tr>
</table>
</div>
</body>
</html>