No announcement yet.

Creating simple thumbnail gallery

  • 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:
      <?  if ($img mysql_fetch_array($imageMYSQL_ASSOC)) { ?>
      <? do { ?>
        <td><img src="<? echo $img[filename]?>"></td>
    <? } while ($img mysql_fetch_array($imageMYSQL_ASSOC)); 
         } else {}
    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:

    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;

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

    else {
    some code here :D - 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!


    • #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.



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

        if( $i % 4 == 0 ){


        • #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.


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