Visualizzazione dei risultati da 1 a 10 su 14

Discussione: Impaginazione gallery

Visualizzazione discussione

  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    360

    Impaginazione gallery

    Salve,

    uso quetso codice per una image gallery
    Codice PHP:
    <?php 
        
    include("config.inc.php"); 

        
    // initialization 
        
    $result_array = array(); 
        
    $counter 0

        
    $cid = (int)($_GET['cid']); 
        
    $pid = (int)($_GET['pid']); 

        
    // Category Listing 

        
    if( empty($cid) && empty($pid) ) 
        { 
            
    $number_of_categories_in_row 4

            
    $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 ) ) 
            { 
                
    $result_array[] = "[url='viewgallery.php?cid=".$row[0]."']".$row[1]."[/url] "."(".$row[2].")"
            } 
            
    mysql_free_result$result );     

            
    $result_final "<tr>\n"

            foreach(
    $result_array as $category_link
            { 
                if(
    $counter == $number_of_categories_in_row
                {     
                    
    $counter 1
                    
    $result_final .= "\n</tr>\n<tr>\n"
                } 
                else 
                
    $counter++; 

                
    $result_final .= "\t<td>".$category_link."</td>\n"
            } 

            if(
    $counter
            { 
                if(
    $number_of_categories_in_row-$counter
                
    $result_final .= "\t<td colspan='".($number_of_categories_in_row-$counter)."'></td>\n"

                
    $result_final .= "</tr>"
            } 
        } 


        
    // Thumbnail Listing 

        
    else if( $cid && empty( $pid ) ) 
        { 
            
    $number_of_thumbs_in_row 5

            
    $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 "\t<tr><td>No Category found</td></tr>\n"
            } 
            else 
            { 
                while( 
    $row mysql_fetch_array$result ) ) 
                { 
                    
    $result_array[] = "[url='viewgallery.php?cid=$cid&pid=".$row[0]."'][img]".$images_dir."/tb_".$row[2]."[/img][/url]"
                } 
                
    mysql_free_result$result );     

                
    $result_final "<tr>\n"
         
                foreach(
    $result_array as $thumbnail_link
                { 
                    if(
    $counter == $number_of_thumbs_in_row
                    {     
                        
    $counter 1
                        
    $result_final .= "\n</tr>\n<tr>\n"
                    } 
                    else 
                    
    $counter++; 

                    
    $result_final .= "\t<td>".$thumbnail_link."</td>\n"
                } 
         
                if(
    $counter
                { 
                    if(
    $number_of_photos_in_row-$counter
                
    $result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'></td>\n"

                    
    $result_final .= "</tr>"
                } 
            } 
        } 

        
    // 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 "\t<tr><td>No Photo found</td></tr>\n"
            } 
            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 .= "<tr>\n\t<td> 
                            [url='viewgallery.php']Categories[/url] &gt;  
                            [url='viewgallery.php?cid=
    $cid']$category_name[/url]</td>\n</tr>\n"

                
    $result_final .= "<tr>\n\t<td align='center'> 
                        
     
                        [img]"
    .$images_dir."/".$photo_filename."[/img] 
                        
     
                        
    $photo_caption 
                        </td> 
                        </tr>"

            } 
        } 

    // Final Output 
    echo <<<__HTML_END 

    <html
    <
    head
        <
    title>Gallery View</title
    </
    head
    <
    body
    <
    table width='100%' border='0' align='center' style='width: 100%;'
    $result_final         
    </table
    </
    body
    </
    html

    __HTML_END
    ?>
    e permette:

    - visualizzazione link gallerie
    - possibilità di entrare in una categoria della galleria con visualizzazione miniature foto
    - clic su una miniatura per ingradimento foto

    vorrei impaginare però la cosa come quello che allego, parlo del PHP, non del codice CSS. Le gallerie 05, 06, 07, 08, ecc, sarebbero visualizzabili cambiando pagina, andando alla 2, con la paginazione in basso.

    Vedo una complessità, ovvero quella di fare più SELECT e separate nella stessa pagina, fino ad ora avevo fatto sempre SELECT singole che visualizzavano ad esempio una galleria alla volta, ma in questo caso devo poter visualizzare più categorie contemporaneamente.
    Immagini allegate Immagini allegate

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.