Mediante la guida presente su php.html.it ho creato la mia galleria d'immagini personale.


Sono giorni che la guardo e la riguardo ma non trovo l'errore. A video nn stampa un errore ma è come se ci fosse, perchè se c'è una sola immagine, allora lo script funziona correttamente, ma appena glie ne si aggiunge un'altra o di + lo script aggiunge delle pagine e anche se le si cliccano le immagini rimangono sempre le stesse, non cambia pagina.. Spero di essermi spiegato bene, di seguito vi riporto il codice della galleria:

Codice PHP:
<table cellpadding="2" cellspacing="0" border="0" width="100%">
<?php
if (isset($_GET['tid']))
{

$tid $_GET['tid'];

if (!isset(
$start) OR $start<0)
{
$start 0;

$step 4;

$query1 "SELECT * FROM tfn_images WHERE tid='$tid' AND type='a' ORDER BY id DESC LIMIT $start$step";

$results1 mysql_query($query1) or die (mysql_error());

while (
$row1 mysql_fetch_array($results1))
{
    
$tid $_GET['tid'];
    
      
$width 150;
  
  
$div $row1['width'] / $width;
  
$nh $row1['height'] / $div;
            
            echo 
"<tr><td align=\"center\" width=\"40%\"><a href=\"$row1[image]\"><img src=\"$row1[image]\" width=\"$width\" height=\"$nh\" /></a></td><td style=\"background-color: #ECE9D8;\" valign=\"top\">[i]$row1[description][/i]</td></tr>";
            
            
}
}
}
else
{
if (!isset(
$start) OR $start<0)
{
$start 0;

$step 4;

$query4 "SELECT * FROM tfn_images WHERE type='a' ORDER BY id DESC LIMIT $start$step";

$results4 mysql_query($query4) or die (mysql_error());

while(
$row4 mysql_fetch_array($results4))
{
      
$width 150;
  
  
$div $row4['width'] / $width;
  
$nh $row4['height'] / $div;
            
            echo 
"<tr><td align=\"center\" width=\"40%\"><a href=\"$row4[image]\"><img src=\"$row4[image]\" width=\"$width\" height=\"$nh\" /></a></td><td style=\"background-color: #ECE9D8;\" valign=\"top\">[i]$row4[description][/i]</td></tr>";
            
            
}
}
}
?>
</table>

<table width="90%" border="0" style="padding-top: 100px;" align="center">

    <tr>

     <td width="20%" align="left">

<?php

if ($start>0)
{
    
    
$start_back $start $step;
    
    if(isset(
$_GET['tid']))
    {
    
$tid $_GET['tid'];
    
    echo 
"<a href=\"gallery.php?start=$start_back&amp;tid=$tid\">Precedenti</a>";
    }
    else 
    {
    echo 
"<a href=\"gallery.php?start=$start_back\">Precedenti</a>";
    }
}

?>

</td>

<?php

$query2 
"SELECT count(type='a') AS tot FROM tfn_images";

$results2 mysql_query($query2$db);

$row2 mysql_fetch_array($results2);

$pages intval(($row2['tot']-1) / $step)+1;

?>

<td width="60%" align="right">

<?php

for($i=0$i<$pages AND $i<4$i++)
{
    if(isset(
$_GET['tid']))
    {
    
$tid $_GET['tid'];
    
    echo 
"<a href=\"gallery.php?start=$pages&amp;tid=$tid\">". ($i+1) ."</a>";
    }
    else
    {
    echo 
"<a href=\"gallery.php?start=$pages\">". ($i+1) ."</a>";
    }
}

?>

     </td>
    
     <td width="20%" align="left">

<?php

if ($start $step $row2['tot'])
{
    
$start_next $start $step;
    if(isset(
$_GET['tid']))
    {
    
$tid $_GET['tid'];
    
    echo 
"<a href=\"gallery.php?start=$start_next&amp;tid=$tid\">Successivi</a>";
    }
    else
    {
    echo 
"<a href=\"gallery.php?start=$start_next\">Successivi</a>";
    }
}
?>

    </td>
   </tr>
</table>

<?php



mysql_close 
($db);

?>