Ciao ragazzi spero che possiate aiutarmi..

mastico pochissimo php e come smanettone riesco a fare un bel copia e incolla dei vari script in php..

il mio problema: sono riuscito a far stampare la mia galleria uppata tramite parte admin.. ma non riesco a metterci la paginazione.. vi posto il codice.. se potete aiutarmi ve ne sarei grato così finirò il sito:


Codice PHP:
<?php
include "./gestione/config.inc.php";
?>

        <div class="wp-pagenavi">
            <ul>
                [*]<span class="pages">Page 1 of 7</span>
                [*][url="#"][/url]
                [*][url="#"]&lsaquo;[/url]
                [*]
                <?php
                 
/* LISTA CATEGORIE */
                // initialization
    
$result_array = array();
    
$counter 0;

    
$cid = (int)($_GET['cid']);
    
$pid = (int)($_GET['pid']);
    
$result mysql_query"SELECT c.category_id,c.category_name,COUNT(photo_id)
                        FROM gallery_category as c
                        LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id
                        GROUP BY c.category_id" 
);
        while( 
$row mysql_fetch_array$result ) )
        {
            echo 
"<span class='current'>[url='?cid=".$row[0]."']".$row[1]."[/url]</span> ";    
}
?>    
    [*][url="#"]&rsaquo;[/url]
                [*][url="#"][/url]
            [/list]
        </div>   
<div class="clear1"></div>
                 
<div class="gallery">
            
    <?php 
    
// Thumbnail Listing

     
if( $cid && empty( $pid ) )
    {
        
$number_of_thumbs_in_row 1;

        
$result mysql_query"SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'" );
        
$nr mysql_num_rows$result );

        if( empty( 
$nr ) )
        {
            
$result_final "Nessuna Foto Trovata";
        }
        else
        {
            while( 
$row mysql_fetch_array$result ) )
            {
                
$result_array[] = "
                <ul>
                [*]
                    <div class='gallery_item'>[img]"
.$images_dir."/tb_".$row[2]."[/img]
                    

"
.$photo_caption."</p>    
            
            <center>[url='?cid=
$cid&pid=".$row[0]."']CLICCA PER INGRANDIRE[/url]</center></div>
                
                [/list]"
;
            }
            
mysql_free_result$result );    

            
$result_final "";
    
            foreach(
$result_array as $thumbnail_link)
            {
                if(
$counter == $number_of_thumbs_in_row)
                {    
                    
$counter 1;
                    
$result_final .= "";
                }
                else
                
$counter++;

                
$result_final .= "".$thumbnail_link."";
            }
    
            if(
$counter)
            {
                if(
$number_of_photos_in_row-$counter)
            
$result_final .= "".($number_of_photos_in_row-$counter)."";

                
$result_final .= "";
            }
        }
    }

    
// Full Size View of Photo
    
else if( $pid )
    {
        
$result mysql_query"SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
        list(
$photo_caption$photo_filename) = mysql_fetch_array$result );
        
$nr mysql_num_rows$result );
        
mysql_free_result$result );    

        if( empty( 
$nr ) )
        {
            
$result_final "Nessuna foto trovata";
        }
        else
        {
            
$result mysql_query"SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
            list(
$category_name) = mysql_fetch_array$result );
            
mysql_free_result$result );    

            
$result_final .= "
                        <div id='mostracategoria'>[url='']CATEGORIA[/url] &gt; 
                        [url='?cid=
$cid']$category_name[/url]</div>";

            
$result_final .= "
                    <div id='mostragalleria'>

                    [img]"
.$images_dir."/".$photo_filename."[/img]
                    


        <p style=' text-shadow: 1px 1px 1px #999; font-size: 15px; font-weight: bold;'> 
$photo_caption</p>
                    </div>"
;
        }
    }

// Final Output


echo $result_final "

?>             
                
            <div class="clear">
            
            </div>
        </div>
        
                  
              </div>
              <div id="paginate">
               <?php
require_once './gestione/class.ycpager.php';

//Imposto i dati del database
$host 'localhost';
$username 'utente';
$password 'password';
$database 'galleria';

//Connessione al database
$conn mysql_connect($host$username$password) or die('Errore di connessione');
mysql_select_db$database );

//Ottengo il numero delle pagine totali.
$total mysql_query"SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'");
$numero_notizie mysql_num_rows$total );

if( 
$numero_notizie ) {
    
$limite 10;
    
    
//Pagina attuale
    
$p = !empty($_GET['p']) ? $_GET['p'] : 1;
    
    
$redirect_to 'galleria.php';
    
    
//Inizializzo YCPager
    
$pager = new YCPager$p$numero_notizie$limite$redirect_to );
    
    
//Ottengo l'Offset da usare nella query successiva
    
$offset $pager->getQueryOffset();
    
    
//Ottengo le notizie paginate
    
$notizie mysql_query'SELECT photo_id FROM gallery_photos LIMIT ' $limite ' OFFSET ' $offset );
    
    while( 
$row mysql_fetch_assoc($notizie)) {
        echo 
$row['id'] . '
'
;
    }
    
    
//Stampo la paginazione
    
$pager->getPager();
}
?>
</div>
La parte di paginazione ho cercato di farla funzionare con un'esercizio preso da yourinspirationweb ma ci sto perdendo tempo da mesi ormai e non ci sto camendo una mazza

Spero che mi possiate aiutare..


Grazie.