Announcement

Collapse
No announcement yet.

Creating simple thumbnail gallery

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating simple thumbnail gallery

    Hey, I'm trying to create a relatively simple photo thumbnail gallery. No GD or anything like that (yet, anyway), just pulling filenames from a database and putting the images into a table.

    Currently I've got this:

    PHP Code:
      <tr> 
      <?  if ($img mysql_fetch_array($imageMYSQL_ASSOC)) { ?>
      <? do { ?>
        <td><img src="<? echo $img[filename]?>"></td>
        
    <? } while ($img mysql_fetch_array($imageMYSQL_ASSOC)); 
                          
         } else {}
        
    ?>
      </tr>
    The problem is I don't know how to make it so that it starts a new row every four columns. Anyone have any simple tips on how to make it start a new row every four thumbnails?

    Thanks in advance.

  • #2
    Ok, this gets a little tricky, just think a little more in terms of numbers. I did this with an online store I made, example of the output: http://leggett.ca/fastone/index.php?cid=7

    I puts 2 products per column then starts an new row.

    Something like this:

    PHP Code:
    //Check if record number is divisible by 2 (Or whatever you want here)
           
    $current_record $current_record +1;
           
    $check_count $current_record 2;

        
    //EVEN DIVISION - END ROW
            
    if (!eregi("\."$check_count)) {
    print 
    "<td valign=\"top\" width=\"50%\">\n";
    //end if

            
            //ODD DIVISION - START NEW ROW
            
    else {
    some code here :D

    WebHostGear.com - Server Tutorials, Web Server Guides, Hosting Tutorials
    As seen in Ping Zine Magazine
    Preventing Brute Force Attacks | APF Firewall Install Guide |Cpanel FTP Backup Script Now Available!

    Comment


    • #3
      I am interested in this. Are you planning on releasing the code you use? I just need a simple gallery that shows thumbnails of images uploaded, and the ability to list specific users photos.

      Thanks!!

      Comment


      • #4
        Surely a more efficient method of coding would be to use

        if( $i % 4 == 0 ){

        Comment


        • #5
          Personally, I load the details into an array, and check for the size of that array at each loop iteration, if its the required number (i.e. 2 per row) it outputs the data, if not, it loops until it is.

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X