SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    gallery ablum links to drop down menu

    Hi

    I am trying to make all my gallery album links into a drop down menu any ideas how to do this?

    Here is my code for the links

    Code:
    <?php
    	include("CMS/config.inc.php");
    	$images_dir1 = 'CMS/gallery/photos';
    	// initialization
    	$result_array = array();
    	$counter = 0;
    
    	$cid = (int)($_GET['cid']);
    	$pid = (int)($_GET['pid']);
    
    	// Category Listing
    
    		$number_of_categories_in_row = 1;
    
    		$result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id)
    						FROM ch_gallery_category as c
    						LEFT JOIN ch_gallery_photos as p ON p.photo_category = c.category_id
    						GROUP BY c.category_id" );
    		while( $row = mysql_fetch_array( $result ) )
    		{
    			$result_array[] = "<a href='./gallery.php?cid=".$row[0]."' class='cat_list' alt='".$row[1]."' title='".$row[1]."'>".$row[1]."</a>";	
    		}
    		mysql_free_result( $result );	
    
    		$result_final = "<table cellpadding='5' align='center'><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 align='center'>".$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></table>";
    		}
    
    
    
    // Final Output
    echo <<<__HTML_END
    <div>
      $result_final
    </div>	
    __HTML_END;
    ?>
    Thanks guys

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the PHP enclosures rather than CODE enclosures for PHP code. Makes it a little easier to read when the syntax is highlighted :3.

    K what's going wrong? I didn't see any output. Can you post the output as well as the expected output?

    PHP Code:
    <?php
        
    include("CMS/config.inc.php");
        
    $images_dir1 'CMS/gallery/photos';
        
    // initialization
        
    $result_array = array();
        
    $counter 0;

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

        
    // Category Listing

            
    $number_of_categories_in_row 1;

            
    $result mysql_query"SELECT c.category_id,c.category_name,COUNT(photo_id)
                            FROM ch_gallery_category as c
                            LEFT JOIN ch_gallery_photos as p ON p.photo_category = c.category_id
                            GROUP BY c.category_id" 
    );
            while( 
    $row mysql_fetch_array$result ) )
            {
                
    $result_array[] = "<a href='./gallery.php?cid=".$row[0]."' class='cat_list' alt='".$row[1]."' title='".$row[1]."'>".$row[1]."</a>";    
            }
            
    mysql_free_result$result );    

            
    $result_final "<table cellpadding='5' align='center'><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 align='center'>".$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></table>";
            }



    // Final Output
    echo <<<__HTML_END
    <div>
      
    $result_final
    </div>    
    __HTML_END;
    ?>
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi guys I was away for the weekend,

    What i am trying to do is when the album names for gallery outputs as a list of links I want the list to be within a dropdown menu?

    thanks


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
  •