I display thumbnail image previews for my website using a while loop. Each time the loop goes through 6 thumbnails it starts a new line - basicly giving columns and rows.
The images have naming conventions like this:
category_name_2nd category colour(not all have a 2nd a category).jpg e.g.
mountainbike_handlebar_black.jpg
In the loop I need to display images with and without a 2nd category i.e.
mountainbike_handlebar_black.jpg
mountainbike_handlebar.jpg
For the below code I tried to put a preg_match if statement around this (image names are in the url and so you can use a preg_match on a GET):
$files = "http://localhost/images/small/".$image_name[0].".jpg";
But no luck - this displays all images with a second category only.
So please suggest how I would tackle this and get all images displaying.
....
echo "<table align='center' cellspacing='7px' cellpadding='7px'>";
$i = 1;
while ($f = mysql_fetch_array($filelist))
{
echo "<td>";
$image_name_original = $f['filename'];
$image_name = explode(".",$image_name_original);
$files = "http://localhost/images/small/".$image_name[0].".jpg";
echo "<img src='$files' style='text-decoration: none; border: none;' alt='".$f['item_name']."' title='".$f['item_name']."' width='117' height='161' />";
echo "</td> ";
if($i%6 == 0)
{
echo "<tr>";
echo "</tr>";
$i=0;
}
$i = $i+1; // add 1 for each iteration of while loop
}
....
Thanks