SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Gallery article

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    France
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Gallery article

    I'm reading through the Gallery system article, and I don't understand this part of the code that deals with limiting the number of categories displayed per row.

    At the bottom of the code is this:
    PHP Code:
    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>";

    What is the purpose of the if($counter) statement? I mean why check if the counter variabel exists?

    What does this line mean if ($number_of_categories_in_row - $counter)?
    Is that the same as writing $number_of_categories_in_row < $counter ?

    This is the whole code:
    PHP Code:
    The procedure is:


    Fetch the list of all categories, and the number of images each holds

    The number of links in row controlled by value is assigned to $number_of_categories_in_row

    Create display via tables 

    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[] = 
         
    '<a href="viewgallery.php?cid=' $row[0] . '">' 
         
    $row[1] . '</a> (' $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) . "'>&nbsp;</td>\n"

       
    $result_final .= "</tr>"
     } 


  2. #2
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it is a little bit personalized!!!!
    i would make it in another way!!!


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
  •