SitePoint Sponsor

User Tag List

Page 23 of 31 FirstFirst ... 13192021222324252627 ... LastLast
Results 551 to 575 of 767
  1. #551
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    it will be in the upload page.

    look for the lines with these in them:
    PHP Code:
      // Wide Image 
     
    if($size[0] > $size[1]) 
     {  
      
    $thumbnail_width 100;  
      
    $thumbnail_height = (int)(100 $size[1] / $size[0]);  
     }  
      
     
    // Tall Image 
     
    else 
     { 
       
    $thumbnail_width = (int)(100 $size[0] / $size[1]); 
       
    $thumbnail_height 100
     } 
    just change the witdh and hieght (they are set to 100) to suit your needs.

    spence

  2. #552
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Imageswapping within the same HTML page

    Hopefully this thread is still available for posting help requests..

    I'm still working with the tutorial and using Drew's files he has posted.
    I'm getting close to getting the image swapping but my problem is the $final_results being the issue. This string is used for both thumbnails and the final viewing image and I don't know how to seperate the two.

    Attached is simple illustration of what I am trying to achieve. I want to maintain the thumnails along side of the large image.


    Since thumbnail results and view full size use the same variable of $result_final and am not able to put each result into their own DIV tag or HTML table/cell. I am able to get my thumbnails into it's own html table or DIV.

    Here's the code I'm using (and trying) to work with in making the larger image appear on the same page as the thumbnails. Any help with what I need to do is very much appreciated!!

    PHP Code:
            // Thumbnail Listing

            
    else if( $cid && empty( $pid ) )
            {
                    
    $number_of_thumbs_in_row 6;

                    
    // If current page number, use it
                    // if not, set one!

                    
    if(!isset($_GET['page'])){
                        
    $page 1;
                    } else {
                        
    $page $_GET['page'];
                    }

                    
    // Define the number of results per page
                    
    $max_results 42;

                    
    // Figure out the limit for the query based
                    // on the current page number.
                    
    $from = (($page $max_results) - $max_results);

                    
    $result = @mysql_query"SELECT artwork_id,artwork_caption,artwork_filename FROM gallery_artwork WHERE artwork_category='".addslashes($cid)."' LIMIT $from$max_results");

                    
    $nr = @mysql_num_rows$result );

                    if( empty( 
    $nr ) )
                    {
                            
    $result_final "\t<tr><td><div align=\"center\"><strong>No images in category found!</strong>
                                                    <br><br><font size=\"2\"><a href='index.php'>Back to Artwork Gallery Category List</a></font>
                                                    </div></td></tr>\n"
    ;
                    }
                    else
                    {
                            while( 
    $row mysql_fetch_array$result ) )
                            {
                                    
    $result_array[] = "<a href='index.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' cellpadding='0' valign='top' alt='".$row[1]."' /></a>";
                            }
                            
    mysql_free_result$result );

                            
    $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><a href='index.php'>Categories</a> &gt; $category_name<br><br>";
            
                            
    foreach($result_array as $thumbnail_link)
                            {
                                    if(
    $counter == $number_of_thumbs_in_row)
                                    {        
                                            
    $counter 1;
                                            
    $result_final .= $category_link."\n</tr>\n<tr>\n";
                                    }
                                    else
                                    
    $counter++;

                                    
    $result_final .= "\t<td><div align=\"center\">".$thumbnail_link."</div></td>\n";
                            }
            
                            if(
    $counter)
                            {
                                    if(
    $number_of_artwork_in_row)
                            
    $result_final .= "\t<td colspan='".($number_of_thumbs_in_row)."'></td>\n";
                            
    $result_final .= "</tr>\n";
                            
    // Figure out the total number of results in DB:
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_artwork WHERE artwork_category=".addslashes($cid).""),0);

    // Figure out the total number of pages. Always round up using ceil()
    $total_pages ceil($total_results $max_results);

    if (
    $total_pages >1)
    {  
    // build links if more than one page


    // Build Page Number Hyperlinks
    $result_final .=  "<tr><td colspan='".$number_of_thumbs_in_row."'>Showing Page: ".$page.' of '.$total_pages."<br>";


    // Build Previous Link
    if($page 1){
        
    $prev = ($page 1);
        
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$prev\" title='Previous Page'>&lt;&lt; Prev</a>";
    }

    for(
    $i 1$i <= $total_pages$i++){
        if((
    $page) == $i){
            
    $result_final .= "&nbsp;[$i]";
            } else {
                
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$i\" title='Page ".$i."'>$i</a>";
        }
    }

    // Build Next Link
    if($page $total_pages){
        
    $next = ($page 1);
        
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$next\" title='Next Page'>Next &gt;&gt;</a>";
    }
    $result_final .=  "\n</td></tr>";

    }
    else
    {
    $result_final .=  "\n";
    }
    }
    }
    }

          
    // Full Size View of Artwork
         
     
    else if( $pid )
            {
                    
    $result mysql_query"SELECT artwork_caption,artwork_filename FROM gallery_artwork WHERE artwork_id='".addslashes($pid)."'" );
                    list(
    $artwork_caption$artwork_filename) = mysql_fetch_array$result );
                    
    $nr mysql_num_rows$result );
                    
    mysql_free_result$result );        

                    if( empty( 
    $nr ) )
                    {
                            
    $result_final "\t<tr><td>No Artwork 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>
                              //                      <a href='index.php'>Categories</a> &gt;
                              //                      <a href='index.php?cid=$cid'>$category_name (Thumbnail Listing)</a></td>\n</tr>\n";

                            
    $result_final .= "<tr>\n\t<td div id='slide' align='center'>
                                            <br />
                                            <img src='"
    .$images_dir."/".$artwork_filename."' border='0' alt='".$artwork_caption."' />
                                            <br />
                                            </td>
                                            </tr></div>"
    ;
                                           
                    }
                    
            } 
    Attached Images Attached Images
    Last edited by lok1728; Sep 6, 2006 at 22:23. Reason: attached illustration instead of linking.

  3. #553
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, spence_noodle

    I am going through your subcategory module, and am having some troubles/errors. from the start.

    Here are the returned errors:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/roblisa/public_html/gallery/subcategory2.php on line 30

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/roblisa/public_html/gallery/subcategory2.php on line 30

    Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/roblisa/public_html/gallery/subcategory2.php on line 71

    url: http://robandlisa.ca/gallery/subcategory2.php

    I am using your original supplied code (with category_des changed to category_desc):
    <?php
    include("config.inc.php");

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

    // Category Listing

    if( empty($cid) && empty($pid) )
    {
    $number_of_categories_in_row = 1;

    $cat = mysql_query( "SELECT c.category_id,c.category_name,c.category_parent,c.category_desc,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 ORDER BY c.category_desc ASC" );

    while( $row = mysql_fetch_array( $cat ) )
    {
    if($row[2] == 0)
    {
    $cat_array[] = "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'><a href='cat_user.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[4].")</font><br />";
    }

    if($row[2] > 0)
    {
    $subresult = mysql_query("SELECT category_id,category_name,category_parent,category_desc FROM gallery_category WHERE category_name='".$row[1]."' ORDER BY category_desc ASC");

    while( $sub_result = mysql_fetch_array( $subresult ) )
    {
    if ($sub_result[2] !='')
    {
    $line1 = explode('/', $sub_result[3]);

    $line2 = implode(', ', $line1);

    $words1 = preg_replace('/\s+/', '', $line2);

    $words2 = str_replace(',', ' ', $words1);

    $level = substr_count($words2," ");

    if($level == 1)
    {
    $add = str_repeat('&nbsp;', 0);
    }

    if($level == 2)
    {
    $add = str_repeat('&nbsp;', 2);
    }

    if($level == 3)
    {
    $add = str_repeat('&nbsp;', 4);
    }

    $subcat = mysql_query( "SELECT COUNT(photo_id)
    FROM gallery_category as c
    LEFT JOIN gallery_photos as p ON p.photo_category = '".$sub_result[0]."'
    GROUP BY c.category_id ORDER BY c.category_name ASC" );
    $sub_cat = mysql_fetch_array( $subcat );

    $cat_array[] = "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'>".$add."|-<a href='cat_user.php?cid=".$row[0]."'>".$sub_result[1]."</a> "."(".$sub_cat[0].")</font><br />";
    }
    }
    }
    }
    mysql_free_result( $cat );
    mysql_free_result( $subresult );

    foreach($cat_array as $category_link)
    {
    if($counter == $number_of_categories_in_row)
    {
    $counter = 1;
    }
    else
    $counter++;

    $cat_final .= "$category_link";
    }

    }
    //Final result
    echo "$cat_final";
    ?>
    Here's what in the category db:
    category_id bigint(20)
    category_name varchar(50)
    category_parent int(11)
    category_desc varchar(60)
    I am working on making this menu system CSS driven; but, can't get the backend to fly. Please, assist.

  4. #554
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    sorry to hear you are having problems.

    at the moment the only thing i can think what could be causing this is that you have not called the table 'gallery_category', then placed the above fields.

    also a table called 'gallery_photos' with the fields 'photo_id' and 'photo_category'.

    i'll have a more detailed look at it, plus i may have made a newer version.

    will post results, but try them first.

    spence

  5. #555
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    ok Vibex, i've got the subcategory to work. you will need to change category_des to catgeory_desc.

    i think it may have been this:

    COUNT(photo_id) and p.photo_category = c.category_id that was causing the problems

    i've changed the above to this:

    COUNT(p.photo_id) and p.photo_category=c.category_id

    the code below does work, i've tested it on my website.

    PHP Code:
     <?php
     
    include("config.inc.php");
     
     
    // initialization
     
    $cat_array = array();
     
    $counter 0;
     
     
    // Category Listing
     
     
    $number_of_categories_in_row 1;
     
     if( empty(
    $cid) && empty($pid) )
     {
     
     
    $cat mysql_query"SELECT c.category_id, c.category_name, c.category_parent, c.category_des, COUNT(p.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 ORDER BY c.category_des ASC" );
     
         while( 
    $row mysql_fetch_array$cat ) )
         {
             if(
    $row[2] == 0)
             {
                 
    $cat_array[] = "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'><a href='cat_user.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[4].")</font><br />";
                 }
                 
                 if(
    $row[2] > 0)
                 {
                 
    $subresult mysql_query("SELECT category_id,category_name,category_parent,category_des FROM gallery_category WHERE category_name='".$row[1]."' ORDER BY category_des ASC");
                 
                     while( 
    $sub_result mysql_fetch_array$subresult ) )
                     {
                         if (
    $sub_result[2] !='')
                         {
                         
    $line1 explode('/'$sub_result[3]);
                         
                         
    $line2 implode(', '$line1);
                         
                         
    $words1 preg_replace('/\s+/'''$line2);
                         
                         
    $words2 str_replace(','' '$words1);
                         
                         
    $level substr_count($words2," ");
                         
                         if(
    $level == 1)
                         {
                         
    $add str_repeat('&nbsp;'0);
                         }
                         
                         if(
    $level == 2)
                         {
                         
    $add str_repeat('&nbsp;'2);
                         }
                         
                         if(
    $level == 3)
                         {
                         
    $add str_repeat('&nbsp;'4);
                         }
                         
                         
    $subcat mysql_query"SELECT COUNT(p.photo_id)
                         FROM gallery_category as c
                         LEFT JOIN gallery_photos as p ON p.photo_category = '"
    .$sub_result[0]."'
                         GROUP BY c.category_id ORDER BY c.category_name ASC" 
    );
                         
    $sub_cat mysql_fetch_array$subcat );
                         
                         
    $cat_array[] = "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'>".$add."|-<a href='cat_user.php?cid=".$row[0]."'>".$sub_result[1]."</a> "."(".$sub_cat[0].")</font><br />";
                         }
                     }
                 }
             }
             
    mysql_free_result$cat );
             
    mysql_free_result$subresult );
             
             foreach(
    $cat_array as $category_link)
             {
             if(
    $counter == $number_of_categories_in_row)
             {
             
    $counter 1;
             }
             else
             
    $counter++;
         
             
    $cat_final .= "$category_link";
             }
     
     }
     
    //Final result
     
    echo "$cat_final";
     
    ?>
    let us know if thats sorted it out.

    spence

  6. #556
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Spence,

    No Dice. same errors, different lines numbers:
    http://robandlisa.ca/gallery/subcategory2.php

    I'm missing something, here, that I am blinded to.
    here's the version I am working on, slightly different structuring; but, the same errors.

    Thanks for all the help.

  7. #557
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    whats your tables look like in mysql?

    are they like this:

    gallery_category:

    PHP Code:
      -- 
      -- 
    Table structure for table `gallery_category`
      -- 
      
      
    CREATE TABLE `gallery_category` (
        `
    category_idbigint(20unsigned NOT NULL auto_increment,
        `
    category_namevarchar(250NOT NULL default '',
        `
    category_parentbigint(250NOT NULL default '0',
        `
    category_descvarchar(250NOT NULL default '',
        
    PRIMARY KEY  (`category_id`),
        
    KEY `category_id` (`category_name`)
      ) 
    TYPE=MyISAM AUTO_INCREMENT=180 
    gallery_photos:
    PHP Code:
      -- 
      -- 
    Table structure for table `gallery_photos`
      -- 
      
      
    CREATE TABLE `gallery_photos` (
        `
    photo_idbigint(20unsigned NOT NULL auto_increment,
        `
    photo_categorybigint(20) default NULL,
        
    PRIMARY KEY  (`photo_id`),
        
    KEY `photo_id` (`photo_category`)
      ) 
    TYPE=MyISAM AUTO_INCREMENT=343 
    with gallery_photos there will be more fields, above is just for the script above.

    spence

  8. #558
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    gallery_category
    CREATE TABLE `gallery_category` (
    `category_id` bigint(20) unsigned NOT NULL auto_increment,
    `category_name` varchar(50) NOT NULL default '0',
    `category_parent` int(11) NOT NULL default '0',
    `category_desc` varchar(60) NOT NULL default '',
    PRIMARY KEY (`category_id`),
    KEY `category_id` (`category_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=12 ;
    gallery_photos
    CREATE TABLE `gallery_photos` (
    `photo_id` bigint(20) unsigned NOT NULL auto_increment,
    `photo_filename` varchar(25) default NULL,
    `photo_caption` text,
    `photo_category` bigint(20) unsigned NOT NULL default '0',
    `photo_dateadded` datetime NOT NULL default '0000-00-00 00:00:00',
    `photo_order` tinyint(20) unsigned NOT NULL default '13',
    PRIMARY KEY (`photo_id`),
    KEY `photo_id` (`photo_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=202 ;

  9. #559
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    is there any categories within the gallery_category table?

    your mysql tables look fine, just want to know if theres any data been inputed into the gallery_category table.

    spence

  10. #560
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found the error, but don't know the solutions.

    data entered into the database included an apostrophe ' in the category name.

    this caused the errors.
    ______________________________________________________
    Vinyl Records - vinylrecords.ca - New, Used, Collectors Records

  11. #561
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    did you enter the data through phpmyadmin?

  12. #562
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used the admin.php interface to add the category and remove the 's from the category.
    ______________________________________________________
    Vinyl Records - vinylrecords.ca - New, Used, Collectors Records

  13. #563
    SitePoint Enthusiast Bill007's Avatar
    Join Date
    Jul 2006
    Location
    New plymouth, New Zealand
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink The thread Is alive still How amazing Might help someone

    I thought this might be handy an improved Catergory Gallery view
    Example Below
    viewgallery.phpviewgallery.php
    a main catergory gallery with category and image link

    Any way this has been a great journey and i have built a fine gallery site for Artist Friend THANKS TO THIS FINE THREAD and all the people who have developed it Its been great to see how some have taken beyond

    Cool Guys

    Oh and Hi Spence Doodle

    PHP Code:
    include("tools/config.inc.php");
        include(
    "design.inc.php");
        
    //include("latest_photos_added.php");
        // initialization
        
    $design_header;
        
    $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 1;

            
    $result mysql_query"SELECT c.category_id, c.category_name, photo_filename, 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[] = "<b><a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[3].")</b><br /><hr />
                <a href='viewgallery.php?cid="
    .$row[0]."'><img src='".$images_dir."/tb_".$row[2]."'></a>"

            
            }
                                    
            
    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)."'>&nbsp;</td>\n";

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

        
    // Thumbnail Listing

        
    else if( $cid && empty( $pid ) )
        {
            
    $number_of_thumbs_in_row 2;
        
    // If current page number, use it 
            // if not, set one! 

            
    if(!isset($_GET['page'])){ 
                
    $page 1
            } else { 
                
    $page $_GET['page']; 
            } 

            
    // Define the number of results per page 
            
    $max_results 8
            
            
    // Figure out the limit for the query based 
            // on the current page number. 
            
    $from = (($page $max_results) - $max_results); 
            
    $result mysql_query"SELECT photo_id,photo_caption,photo_description,photo_price,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'LIMIT $from$max_results);
            
    $nr mysql_num_rows$result );
            if( empty( 
    $nr ) )
            {
                
    //$design_header
                
    $result_final "\t<tr><td><h1>No Category found</h1></td></tr>\n";
                
    //$design_footer
            
    }
            else
            {
                while( 
    $row mysql_fetch_array$result ) )
                {
                    
                    
                    
    $result_array[] = "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'>
                                       <img src='"
    .$images_dir."/tb_".$row[4]."' border='2' alt='".$row[1]."'</a> <br />
                                       <a href='viewgallery.php?cid=
    $cid&pid=".$row[0]."'>".$row[3]."<br />".$row[1]."</a>";
                
                
                
    // $result_array[] ="<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> ";
                
                
    }
                
    mysql_free_result$result );    
                
    //$design_header
                
    $result_final "<tr>\n";
                
    //$design_footer
                
    foreach($result_array as $thumbnail_link)
                {
                    if(
    $counter == $number_of_thumbs_in_row)
                    {    
                        
    $counter 1;
                        
    $result_final .= "\n</tr>\n<tr>\n";
                    }
                    else
                    
    $counter++;
                   
    // $design_header
                    
    $result_final .= "\t<td>".$thumbnail_link."</td>\n";
                   
    // $design_footer
                
    }
        
                if(
    $counter)
                {
                    if(
    $number_of_photos_in_row-$counter)
                
    $result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'>&nbsp;</td>\n";
                    
                    
    $result_final.= "</tr>\n";
                  
    // Figure out the total number of results in DB: 
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_category=".addslashes($cid).""),0); 

    // Figure out the total number of pages. Always round up using ceil() 
    $total_pages ceil($total_results $max_results); 

    if (
    $total_pages >1)
    {  
    // build links if more than one page


    // Build Page Number Hyperlinks 
    $result_final .=  "<tr><td colspan='".$number_of_thumbs_in_row."' class='tcat'>\nPages&nbsp;(".$total_pages."):&nbsp;"


    // Build Previous Link 
    if($page 1){ 
        
    $prev = ($page 1); 
        
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$prev\" title='Previous Page'>&lt;&lt;</a>"


    for(
    $i 1$i <= $total_pages$i++){ 
        if((
    $page) == $i){ 
            
    $result_final .= "&nbsp;[$i]"
            } else { 
                
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$i\" title='Page ".$i."'>$i</a>"
        } 


    // Build Next Link 
    if($page $total_pages){ 
        
    $next = ($page 1); 
        
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$next\" title='Next Page'>&gt;&gt;</a>"

    $result_final .=  "\n</td></tr>"

    }
    else
    {
    $result_final .=  "\n";
    }            
    }
    }
    }
        
    // Full Size View of Photo
        
    else if( $pid )
        {
            
    $result mysql_query"SELECT photo_description,photo_price,photo_caption,photo_filename,photo_category FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
            list(
    $photo_description,$photo_price,$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 align='center'>
                                  <h3><a href='viewgallery.php'>Return to Art Series List</a> &gt; 
                                  <a href='viewgallery.php?cid=
    $cid'>You are viewing the Art Series of $category_name</a></h3></td>\n  </tr>\n";
                
    $result_final .= "<tr>\n\t<td align='center'>
                                  <h1>
    $photo_caption</h1>
                                  <br />
                                  <h2>
    $photo_price</h2><br />$photo_description<br />
                                  <a href='http://www.art-light.co.nz/security_image/contact.php'>To Purchase this Art piece Contact me</a></p>
                                  <br />
                                  <img src='"
    .$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
                                  <br />
                                  </td>
                        </tr>"
    ;
    }        
    }    
    $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 );
    // Final Output
    echo <<<__HTML_END

    $design_header
    <h1 align='center'>  Art Light Gallery Rooms<br /><br />
    <table width='100%' border='0' align='centre' style='width: 50%;';>
    $result_final        
    </table><br /><br /><br /><br />
    $design_footer
    __HTML_END; 
    Also at the bottom of this script is some code

    eg below

    $design_header
    <h1 align='center'> Art Light Gallery Rooms<br /><br />
    <table width='100%' border='0' align='centre' style='width: 50%;';>
    $result_final
    </table><br /><br /><br /><br />
    $design_footer

    This is how you bring in your own design put your template site design in between the appropriate Variable $design_header=<<<__HTML_END or $design_footer=<<<__HTML_END no white space after <<<__HTML_END or it wont work

    PHP Code:
    <?php
    $design_header
    =<<<__HTML_END
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <meta http-equiv="content-type"content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" type="text/css" href="#" />
    </head>
    <body>
    <div id="header">
    </div> 
    <div id="content">
    __HTML_END;


    $design_footer=<<<__HTML_END
    <div id="footer">
    </div>
    </div>
    __HTML_END;
    ?>
    If anyone wants more I can give you more have some great back end features and other script for this project

    Over and out Bill007 the Kiwi down under

  14. #564
    SitePoint Enthusiast Bill007's Avatar
    Join Date
    Jul 2006
    Location
    New plymouth, New Zealand
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink Those MYSQL Warnings May be this will help

    Kia ora VibeX and Spence doodle

    Hi its Bill007 I think youll find VibeX that you need to adjust your $row [ ?] variables thru out your script do it by trial and error or go to your http://localhost/phpmyadmin/ AND INVESTIGATE THE ROW NUMBERS sounds like its set up for spence doodles Database table which is why it works for him first time
    I had the same problem but then realized that the database rows where culprit behind those MYSQL WARNINGS you need to find out your exact table rows number in the Database


    PHP Code:
    $cat_array[] = "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'><a href='cat_user.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[4].")</font><br />";
                }
                
                if(
    $row[2] > 0)
                {
                
    $subresult mysql_query("SELECT category_id,category_name,category_parent,category_des FROM gallery_category WHERE category_name='".$row[1]."' ORDER BY category_des ASC"); 
    Good luck Ill keep tuned in BILL007

  15. #565
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    hi Bill007, thankx for the scipt above and it's nice to see someone who likes our script snippets to help others along.

    as for the above answer, yes, oh my god! thats it, got to be. his table must be (will be different) and will be getting the info in a different order, etc...

    again thanx for pointing that out, i've been busy learning CISCO (ccna) and job hunting.

    spence

  16. #566
    SitePoint Enthusiast Bill007's Avatar
    Join Date
    Jul 2006
    Location
    New plymouth, New Zealand
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink

    Hey sorry for the spence doodle phrase I feel terrible

    Well Ive been outa the loop with me Holiday

    Poor excuse (holiday Glow has since passed)

    You thinking of an Networking job

    Good luck My sister is in london at the moment working for some IT company getting paid truck loads So some one of your Talent should be scooped up immediately

  17. #567
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    well, you would think so. i've had my CV on Monster.co.uk for nearly two weeks and nothing as yet.

    don't worry about the doodle thing, i've been called much worse, just the other day for example, but I won't go into that, too rude. lol

    london seems to place for IT at the mo, but i'm trying for a much nearer job up north(west) area. I will wait and see.

    cheers,

    spence

  18. #568
    SitePoint Enthusiast Bill007's Avatar
    Join Date
    Jul 2006
    Location
    New plymouth, New Zealand
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Spence Noodle Can you help with your search script

    I want to able to search Categories As-well can you do it with a MYSQL LEFT JOIN

    By the Way what a great Search Script and I love the way it displays

    Nice One


    PHP Code:
    <?php
              
    include "tools/config.inc.php";
              include 
    "design.inc.php";
              
    $query_array = array();
              
    $counter 0;
      
              
    // get the word from the html address
              
    if (!isset($_GET['searchword'])){
                  
    // recieve the word to search from search form
                  
    $word $_POST['word'];
                  
    $dbword $word;
                  
    // insert the word into the database
                
    mysql_query"INSERT INTO gallery_search (search_date, search_word) VALUES(NOW(), '".$word."') ");
              } else {
                
    // if no word from the form has been sent $_GET the word instead from the html address
                  
    $searchw $_GET['searchword'];
                  
    // select the word from the database
                
    $search mysql_query"SELECT search_word, search_date FROM gallery_search WHERE search_word='".$searchw."' ");
                  
    $searchwr mysql_fetch_array$search );
                  
    $dbword $searchwr[0];
              }
              
              
    $number_of_thumbs_in_row 2;
      
              
    // if current page number, use it
              // if not, set one!
              
    if(!isset($_GET['page'])){
                  
    $page 1;
              } else {
                  
    $page $_GET['page'];
              }
      
              
    // define the number of results per page
              
    $max_results 8;
      
              
    // figure out the limit for the query based
              // on the current page number.
              
    $from = (($page $max_results) - $max_results);
      
                    
    // query the database for this word in boolean mode
                 
    $query = @mysql_query"SELECT photo_id, photo_filename, photo_caption, photo_description,photo_price, photo_category,photo_date FROM gallery_photos WHERE photo_caption LIKE '%".$dbword."%' OR photo_description LIKE '%".$dbword."%' OR photo_price LIKE '%".$dbword."%'OR photo_category LIKE '%".$dbword."%' ORDER BY photo_date DESC LIMIT $from$max_results");
      
                    
    $nr = @mysql_num_rows$query );
                      
                      
    // check $nr for results
                      
    if( empty( $nr ) )
                      {
                         
    // if no reults display message below
                         
    $query_final "<tr><td><div align=\"center\"><font face='Verdana, Arial, Helvetica, sans-serif' bgcolor='#C9F9F9' size='4'><span class='style5'><h1>No Art Works found! Please try another word or phrase</h1><a href='../index.php'>Back to Administration Page</a><br /></span></font></div></td></tr>";
                      }
                      else
                      {
                         while( 
    $row mysql_fetch_array$query ) )
                         {                          
                          
    // if word found get each photo and add padding on the left and right
                          
    $image_size getimagesize$images_dir.'/tb_'.$row[1] );
                          
                          if(
    $image_size[0] < 100)
                          {
                               
    $width_size = (int)(120 $image_size[0]);
                               
    $pad_r = (int)($width_size 2);
                               
    $pad_l $pad_r;
                          }
                          else
                          {
                               
    $pad_r 10;
                               
    $pad_l 10;
                          }
                          
                          
    // list thumbnail(s) with details, etc..
                          
    $catquery = @mysql_query"SELECT category_name, category_id FROM gallery_category WHERE category_id='".addslashes($row[5])."'" );
                              list(
    $category_name$category_id) = mysql_fetch_array$catquery );
                              
    mysql_free_result$catquery );
                              
                              
    $query_array[] = "<tr>
                                  <td>
                                   <table align='center' width='50%' border='0' cellspacing='1' cellpadding='1'>
            <tr>
            <td width='20%'  rowspan='10' class='photo_boarder' bgcolor='#C9F9F9'><div align='center'><a href='"
    .$images_dir."/".$row[1]."'><img src='".$images_dir."/tb_".$row[1]."' border='0' alt='".$row[3]."' style='padding-top: 5px; padding-right: ".$pad_r."px; padding-left: ".$pad_l."px; padding-bottom: 5px;' /></a></div>
              </td>

         <td width='300' valign='top' bgcolor='#C9F9F9'><span class='style5'><b>Art Title :</b></span> 
    $row[2] </td>
            </tr>
            <tr>
            <td valign='top'><span class='style5'><b>Art Category :</b></span> 
    $category_name </td>
            </tr>
            <tr>
            <td valign='top' bgcolor='#C9F9F9'><span class='style5'><font color='#FF0000'> <a href='http://art-light.co.nz/contact.php'><b>Buy Now:</b></a></font></span> 
    $row[4] </td>
            </tr>
            <tr>
            <td valign='top'><span class='style5'><b>Date Added :</b></span> 
    $row[6]</td>
            </tr>
            <tr>
              <td valign='top' bgcolor='#C9F9F9'><span class='style5'><b>Photo ID:</b></span> 
    $row[0] </td>
            </tr>
      </table>
          </td>
              </tr>"
    ;
                              }
                         
    mysql_free_result$query );
                            
                         
    // reults - display message below
                         
    $query_final "$design_header<tr><td><div align='center'><font face='Verdana, Arial, Helvetica, sans-serif' size='4' class='style5'><h1>Art Light Search results</h1><br /></font></div></td></tr><br />";
                            
                         
    // loop through until no more adverts can be found with that word
                      
    foreach($query_array as $thumbnail_link)
                              {
                                 if(
    $counter == $number_of_thumbs_in_row)
                                 {        
                                         
    $counter 1;
                                 }
                                 else
                                 
    $counter++;
                              
                              
    $query_final .= "<td><div align=\"center\">".$thumbnail_link."</div></td>";
                              }
                            
                         
    // figure out the total number of results in DB:
                              
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_caption LIKE '%".$dbword."%' OR photo_description LIKE '%".$dbword."%' OR photo_price LIKE '%".$dbword."%' "),0);
                              
                         
    // here check how many thumbs are displayed.
                         // if more than $max_results is set to build page number, prev, next links
                         
    if ($total_results == 8)
                         { 
    // build links for one page only
      
                          // build Page Number Hyperlinks
                              
    $query_final .= "<tr><td colspan='".$number_of_thumbs_in_row."'><span class='style5'><b>Showing Page: 1 of 1</b></span><br><br>";
                            } else {
                          
    // build more than one page if counter is more than 8        
                          // figure out the total number of pages. Always round up using ceil()
                          
    $total_pages ceil($total_results $max_results);
                              
                          
    // build Page Number Hyperlinks
                              
    $query_final .= "<tr><td colspan='".$number_of_thumbs_in_row."'><span class='style5'><b>Showing Page: ".$page.' of '.$total_pages."</b></span><br/>";
                          
                          
    // build Previous Link
                              
    if($page 1){
                                  
    $prev = ($page 1);
                                  
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$prev\" title='Previous Page' class='style5'>&lt;&lt; Prev</a>";
                          }
      
                              
    // build the number of pages
                              
    for($i 1$i <= $total_pages$i++){
                                  if((
    $page) == $i){
                                   
    $query_final .= "&nbsp;[$i]";
                              } else {
                                   
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$i\" title='Page ".$i."' class='style5'>$i</a>";
                              }
                          }
      
                              
    // build Next Link
                              
    if($page $total_pages){
                                  
    $next = ($page 1);
                              
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$next\" title='Next Page' class='style5'>Next &gt;&gt;</a>";
                              
    $query_final .= "</td></tr><br /><br />";
                          }
                          else
                          {
                              
    $query_final .= "<p>";
                          }
          }
      }
      echo 
    "$query_final<br/><br/>";
      
    ?>
    Regards Bill0077

  19. #569
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    cheers Bill007

    yes you could do a LEFT JOIN with the same word.

  20. #570
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    you could do it this way as well:

    PHP Code:
     $query = @mysql_query"SELECT photo_id, photo_filename, photo_caption, photo_description, photo_price, photo_category, photo_date, category_name FROM gallery_photos as a, gallery_category as b WHERE a.photo_caption LIKE '%".$dbword."%' OR a.photo_description LIKE '%".$dbword."%' OR a.photo_price LIKE '%".$dbword."%'OR a.photo_category LIKE '%".$dbword."%' OR b.category_name ORDER BY a.photo_date DESC LIMIT $from$max_results"); 
    spence

  21. #571
    SitePoint Enthusiast Bill007's Avatar
    Join Date
    Jul 2006
    Location
    New plymouth, New Zealand
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Trpple Images from new MSQL search SYNTAX

    Still no Category search Hmmmmm

    And I get triple images out put

    Will do some mucking around with it and see if this thing can work

    I think that search script would be perfect if it could search and retreive Categorys

    Thanks for some direction Though

    Got any clues as to why the triplicate output

    Bill007
    Last edited by Bill007; Oct 7, 2006 at 01:38.

  22. #572
    SitePoint Enthusiast Bill007's Avatar
    Join Date
    Jul 2006
    Location
    New plymouth, New Zealand
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Some more improvements To search.php

    Spence modified the Search.php output a little
    I made links out of the category names and linked the category name and image to a more descriptive and larger image

    Search.php output now flows to the same lines as the viewgallery.php script an example of the search .php in action below
    http://art-light.co.nz/gallery/search.php

    an example of the veiwgallery.phpin action below click on the image
    How the veiwgallery.php script looks as an idea of getting the same look and feel as search php

    search.php Below ties in with viewgallery.php

    PHP Code:
    <?php
              
    include "tools/config.inc.php";
              include 
    "design.inc.php";
              
    $query_array = array();
              
    $counter 0;
      
              
    // get the word from the html address
              
    if (!isset($_GET['searchword'])){
                  
    // recieve the word to search from search form
                  
    $word $_POST['word'];
                  
    $dbword $word;
                  
    // insert the word into the database
                
    mysql_query"INSERT INTO gallery_search (search_date, search_word) VALUES(NOW(), '".$word."') ");
              } else {
                
    // if no word from the form has been sent $_GET the word instead from the html address
                  
    $searchw $_GET['searchword'];
                  
    // select the word from the database
                
    $search mysql_query"SELECT search_word, search_date FROM gallery_search WHERE search_word='".$searchw."' ");
                  
    $searchwr mysql_fetch_array$search );
                  
    $dbword $searchwr[0];
              }
              
              
    $number_of_thumbs_in_row 2;
      
              
    // if current page number, use it
              // if not, set one!
              
    if(!isset($_GET['page'])){
                  
    $page 1;
              } else {
                  
    $page $_GET['page'];
              }
      
              
    // define the number of results per page
              
    $max_results 8;
      
              
    // figure out the limit for the query based
              // on the current page number.
              
    $from = (($page $max_results) - $max_results);
      
                    
    // query the database for this word in boolean mode
                 
    $query = @mysql_query"SELECT photo_id, photo_filename, photo_caption, photo_description,photo_price, photo_category,photo_date FROM gallery_photos WHERE photo_caption LIKE '%".$dbword."%' OR photo_description LIKE '%".$dbword."%' OR photo_price LIKE '%".$dbword."%'OR photo_category LIKE '%".$dbword."%' ORDER BY photo_date DESC LIMIT $from$max_results");
                  
    //$query = @mysql_query( "SELECT photo_id, photo_filename, photo_caption, photo_description, photo_price, photo_category, photo_date, category_name FROM gallery_photos as a, gallery_category as b WHERE a.photo_caption LIKE '%".$dbword."%' OR a.photo_description LIKE '%".$dbword."%' OR a.photo_price LIKE '%".$dbword."%'OR a.photo_category LIKE '%".$dbword."%' OR b.category_name ORDER BY a.photo_date DESC LIMIT $from, $max_results"); 
      
                    
    $nr = @mysql_num_rows$query );
                      
                      
    // check $nr for results
                      
    if( empty( $nr ) )
                      {
                         
    // if no reults display message below
                         
    $query_final "<tr><td><div align=\"center\"><font face='Verdana, Arial, Helvetica, sans-serif' bgcolor='#C9F9F9' size='4'><span class='style5'><h1>No Art Works found! Please try another word or phrase</h1><a href='../index.php'>Back to Administration Page</a><br /></span></font></div></td></tr>";
                      }
                      else
                      {
                         while( 
    $row mysql_fetch_array$query ) )
                         {                          
                          
    // if word found get each photo and add padding on the left and right
                          
    $image_size getimagesize$images_dir.'/tb_'.$row[1] );
                          
                          if(
    $image_size[0] < 100)
                          {
                               
    $width_size = (int)(120 $image_size[0]);
                               
    $pad_r = (int)($width_size 2);
                               
    $pad_l $pad_r;
                          }
                          else
                          {
                               
    $pad_r 20;
                               
    $pad_l 20;
                          }
                          
                          
    // list thumbnail(s) with details, etc..
                          
    $catquery = @mysql_query"SELECT category_name, category_id FROM gallery_category WHERE category_id='".addslashes($row[5])."'" );
                              list(
    $category_name$category_id) = mysql_fetch_array$catquery );
                              
    mysql_free_result$catquery );
                              
                              
    $query_array[] = "<tr>
                                  <td>
                                   <table align='center' width='80%' border='0' cellspacing='1' cellpadding='1'>
            <tr>
            <td width='30%'  rowspan='10' class='photo_boarder' bgcolor='#C9F9F9'><div align='center'><a href='viewgallery.php?cid=
    $cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[1]."' border='0' alt='".$row[3]."' style='padding-top: 5px; padding-right: ".$pad_r."px; padding-left: ".$pad_l."px; padding-bottom: 5px;' /></a></div>
              </td>
         <td width='300' valign='top' bgcolor='#C9F9F9'><span class='style5'><b>Art Title :</b></span> <a href='viewgallery.php?cid=
    $cid&pid=".$row[0]."'>$row[2] </a></td>
            <tr>
            <td valign='top'><span class='style5'><b>Art Category :</b></span> 
    $category_name </td>
            </tr>
            <tr>
            <td valign='top' bgcolor='#C9F9F9'><span class='style5'><font color='#FF0000'> <a href='http://art-light.co.nz/contact.php'><b>Buy Now:</b></a></font></span> 
    $row[4] </td>
            </tr>
            <tr>
            <td valign='top'><span class='style5'><b>Date Added :</b></span> 
    $row[6]</td>
            </tr>
            <tr>
              <td valign='top' bgcolor='#C9F9F9'><span class='style5'><b>Photo ID:</b></span> 
    $row[0] </td>
            </tr>
      </table>
          </td>
              </tr>"
    ;
                              }
                         
    mysql_free_result$query );
                            
                         
    // reults - display message below
                         
    $query_final "$design_header<tr><td><div align='center'><font face='Verdana, Arial, Helvetica, sans-serif' size='4' class='style5'><h1>Art Light Search results</h1><br /></font></div></td></tr><br />";
                            
                         
    // loop through until no more adverts can be found with that word
                      
    foreach($query_array as $thumbnail_link)
                              {
                                 if(
    $counter == $number_of_thumbs_in_row)
                                 {        
                                         
    $counter 1;
                                 }
                                 else
                                 
    $counter++;
                              
                              
    $query_final .= "<td><div >".$thumbnail_link."</div></td>";
                              }
                            
                         
    // figure out the total number of results in DB:
                              
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_caption LIKE '%".$dbword."%' OR photo_description LIKE '%".$dbword."%' OR photo_price LIKE '%".$dbword."%' "),0);
                              
                         
    // here check how many thumbs are displayed.
                         // if more than $max_results is set to build page number, prev, next links
                         
    if ($total_results == 8)
                         { 
    // build links for one page only
      
                          // build Page Number Hyperlinks
                              
    $query_final .= "<tr><td colspan='".$number_of_thumbs_in_row."'><span class='style5'><b>Showing Page: 1 of 1</b></span><br><br>";
                            } else {
                          
    // build more than one page if counter is more than 8        
                          // figure out the total number of pages. Always round up using ceil()
                          
    $total_pages ceil($total_results $max_results);
                              
                          
    // build Page Number Hyperlinks
                              
    $query_final .= "<tr><td colspan='".$number_of_thumbs_in_row."'><span class='style5'><b>Showing Page: ".$page.' of '.$total_pages."</b></span><br/>";
                          
                          
    // build Previous Link
                              
    if($page 1){
                                  
    $prev = ($page 1);
                                  
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$prev\" title='Previous Page' class='style5'>&lt;&lt; Prev</a>";
                          }
      
                              
    // build the number of pages
                              
    for($i 1$i <= $total_pages$i++){
                                  if((
    $page) == $i){
                                   
    $query_final .= "&nbsp;[$i]";
                              } else {
                                   
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$i\" title='Page ".$i."' class='style5'>$i</a>";
                              }
                          }
      
                              
    // build Next Link
                              
    if($page $total_pages){
                                  
    $next = ($page 1);
                              
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$next\" title='Next Page' class='style5'>Next &gt;&gt;</a>";
                              
    $query_final .= "</td></tr><br /><br />";
                          }
                          else
                          {
                              
    $query_final .= "<p>";
                          }
          }
      }
      echo 
    "$query_final<br/><br/>";
      
    ?>
    viewgallery.php


    PHP Code:
    <?php
        
    include("tools/config.inc.php");
        include(
    "design.inc.php");
        
    //include("latest_photos_added.php");
        // initialization
        
    $design_header;
        
    $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 1;

            
    $result mysql_query"SELECT c.category_id, c.category_name, photo_filename, 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[] = "<hr /><b><a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[3].")</b><br />
                <a href='viewgallery.php?cid="
    .$row[0]."'><img src='".$images_dir."/tb_".$row[2]."'></a>"

            
            }
                                    
            
    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)."'>&nbsp;</td>\n";

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

        
    // Thumbnail Listing

        
    else if( $cid && empty( $pid ) )
        {
            
    $number_of_thumbs_in_row 2;
        
    // If current page number, use it 
            // if not, set one! 

            
    if(!isset($_GET['page'])){ 
                
    $page 1
            } else { 
                
    $page $_GET['page']; 
            } 

            
    // Define the number of results per page 
            
    $max_results 8
            
            
    // Figure out the limit for the query based 
            // on the current page number. 
            
    $from = (($page $max_results) - $max_results); 
            
    $result mysql_query"SELECT photo_id,photo_caption,photo_description,photo_price,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'LIMIT $from$max_results);
            
    $nr mysql_num_rows$result );
            if( empty( 
    $nr ) )
            {
                
    //$design_header
                
    $result_final "\t<tr><td><h1>No Category found</h1></td></tr>\n";
                
    //$design_footer
            
    }
            else
            {
                while( 
    $row mysql_fetch_array$result ) )
                {
                    
                    
                    
    $result_array[] = "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'>
                                       <img src='"
    .$images_dir."/tb_".$row[4]."' border='2' alt='".$row[1]."'</a> <br />
                                       <a href='viewgallery.php?cid=
    $cid&pid=".$row[0]."'>".$row[3]."<br />".$row[1]."</a>";
                
                
                
    // $result_array[] ="<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> ";
                
                
    }
                
    mysql_free_result$result );    
                
    //$design_header
                
    $result_final "<tr>\n";
                
    //$design_footer
                
    foreach($result_array as $thumbnail_link)
                {
                    if(
    $counter == $number_of_thumbs_in_row)
                    {    
                        
    $counter 1;
                        
    $result_final .= "\n</tr>\n<tr>\n";
                    }
                    else
                    
    $counter++;
                   
    // $design_header
                    
    $result_final .= "\t<td>".$thumbnail_link."</td>\n";
                   
    // $design_footer
                
    }
        
                if(
    $counter)
                {
                    if(
    $number_of_photos_in_row-$counter)
                
    $result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'>&nbsp;</td>\n";
                    
                    
    $result_final.= "</tr>\n";
                  
    // Figure out the total number of results in DB: 
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_category=".addslashes($cid).""),0); 

    // Figure out the total number of pages. Always round up using ceil() 
    $total_pages ceil($total_results $max_results); 

    if (
    $total_pages >1)
    {  
    // build links if more than one page


    // Build Page Number Hyperlinks 
    $result_final .=  "<tr><td colspan='".$number_of_thumbs_in_row."' class='tcat'>\nPages&nbsp;(".$total_pages."):&nbsp;"


    // Build Previous Link 
    if($page 1){ 
        
    $prev = ($page 1); 
        
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$prev\" title='Previous Page'>&lt;&lt;</a>"


    for(
    $i 1$i <= $total_pages$i++){ 
        if((
    $page) == $i){ 
            
    $result_final .= "&nbsp;[$i]"
            } else { 
                
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$i\" title='Page ".$i."'>$i</a>"
        } 


    // Build Next Link 
    if($page $total_pages){ 
        
    $next = ($page 1); 
        
    $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$next\" title='Next Page'>&gt;&gt;</a>"

    $result_final .=  "\n</td></tr>"

    }
    else
    {
    $result_final .=  "\n";
    }            
    }
    }
    }
        
    // Full Size View of Photo
        
    else if( $pid )
        {
            
    $result mysql_query"SELECT photo_description,photo_price,photo_caption,photo_filename,photo_category FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
            list(
    $photo_description,$photo_price,$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 align='center'>
                                  <h3><a href='viewgallery.php'>Return to Art Series List</a> &gt; 
                                  <a href='viewgallery.php?cid=
    $cid'>You are viewing the Art Series of $category_name</a></h3></td>\n  </tr>\n";
                
    $result_final .= "<tr>\n\t<td align='center'>
                                  <h1>
    $photo_caption</h1>
                                  <br />
                                  <h2>
    $photo_price</h2><br />$photo_description<br />
                                  <a href='http://www.art-light.co.nz/security_image/contact.php'>To Purchase this Art piece Contact me</a></p>
                                  <br />
                                  <img src='"
    .$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
                                  <br />
                                  </td>
                        </tr>"
    ;
    }        
    }    
    $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 );
    // Final Output
    echo <<<__HTML_END

    $design_header
    <h1 align='center'>  Art Lights Main  
    $category_name Gallery Room $cid<br /><br />
    <table width='100%' border='0' align='center' style='width:60%;';>
    $result_final        
    </table><br /><br /><br /><br />
    $design_footer
    __HTML_END;
    ?>
    Regards Bill

  23. #573
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    weldone Bill007, looking very good.

    nice to see you've got it working.

    spence

  24. #574
    SitePoint Addict Coon's Avatar
    Join Date
    Dec 2001
    Location
    Frisco, TX
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could anyone please help me get a video gallery script going on my website? I could pay a little and I would be very grateful.

    Regards

  25. #575
    SitePoint Enthusiast
    Join Date
    Jan 2002
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RSS Feed Generator

    Hey everyone, I absolutly love this gallery and have used some of the codes already suggested here including the Administration page which I think is excellent.

    I have customized my gallery to allow for comments on photos and have just made an RSS Feed out of the gallery. I don't believe anyone has released code to do either of these so I will release the RSS Feed generator first and then depending on how I did with QA'ing how it works release the comments program as well.

    This program is very simple and only requires you to change a few variables, add a field to your categories table and then the program does the rest. It takes a set number of recently updated categories then the most recently added photos from the gallery.

    To see an example of it visit:
    http://www.kbasarab.com/gallery then subscribe to the photo gallery RSS Feed.
    You find download the program from my site's blog.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •