Jump to content

mhnewmedia

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mhnewmedia's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Same result but different method I have set two variables $rowstart and $rowend then when a row is started $rowstart is increased by 1 and when a row is ended $rowend is increased by one then at the end if $rowstart isn't equal to $rowend we print a </tr> I love PHP but sometimes you need a little poke in the right direction!! [code]<?php $i=1; $rowstart = 0; $rowend = 0; while($file = readdir($dh)) { if($file != "." && $file != "..") { $FileName = $file; $NoJPG = str_replace(".jpg","",$FileName); $NoUS = str_replace("_"," ",$NoJPG); if ($i==1){echo "<tr>";     $rowstart++; } print "<td><a href=\"javascript:;\" onmouseover=\"MM_swapImage('MainImage','','gallery/$file',1)\"><img src=\"gallery/thumbs/$file\" border=\"0\" alt=\"$NoUS\"></a></td>"; if ($i==5){echo "</tr>";      $i=0;      $rowend++;      } $i++; $sep = ",\n"; } } if ($rowstart != $rowend){echo "</tr>"; } closedir($dh); ?>[/code]
  2. That Works Like a dream, slight typo on the closing table row tag [code]if ($i==4){print "<\tr>"[/code] should be a forward slash [code]if ($i==4){print "</tr>";[/code] The only other issue is if the number of images is not divisible by 4 then the last table row does not have a closing </tr> tag, I was wondering if there is a way of checking if the number of files is divisible by four and if it isn't then printing a final </tr>
  3. I have written a simple script that acts as a very basic image gallery that basically just reads what files are contained within a directory and displays them as clickable thumbnails which when rolled over display a full size image. [code]      <?php while($file = readdir($dh)) { if($file != "." && $file != "..") { $FileName = $file; $NoJPG = str_replace(".jpg","",$FileName); $NoUS = str_replace("_"," ",$NoJPG); print "<td><a href=\"javascript:;\" onmouseover=\"MM_swapImage('MainImage','','gallery/$file',1)\"><img src=\"gallery/thumbs/$file\" border=\"0\" alt=\"$NoUS\"></a></td>"; $sep = ",\n"; } } closedir($dh); ?> [/code] At the moment the images are dispolyed in table cells that spread across the page horizontally, what i would like to be able to do is display the results in a four column table with as many rows as is needed. Any ideas??
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.