Jump to content

Counter Issues


RChilton

Recommended Posts

So I have product images being added to a website the images are named 77777.jpg or 77777-2.jpg for regular photos and then 77777_1, 77777-2_1, 77777-2_2, etc for the set photos.  Basically I want to restructure our naming of our photos.  Right now the php is using a counter to add the images sequentially.  Now I want to name the set images something like 77777_1a, 77777-2_1a and 77777-2_1d.  Not sure how to change the counter function to add the photos since they are not sequential any more.  The exiting code is below:

if (hasAccessByLevel(6, 'LTE', $userName)){
	echo ("<ul style=\"margin-top:20px;\">
		  <li><a href=\"images/productimages/large_$product[sku].jpg\" class=\"largeImage\">Download large image</a> <em>(right click, save as)</em>
		  </li>");
	if (file_exists("images/productimages/large_$product[sku]_1.jpg")) { //if set photo exists
	  $counter = 0 ;
	  foreach (glob("images/productimages/large_$product[sku]_*.jpg") as $filename) { //Loop through set photos
		  if($counter++ < 0) continue ;
			  echo ("<li><a href=\"images/productimages/large_$product[sku]_$counter.jpg\" class=\"largeImage\">Download large set photo</a>
					 </li>");
		  }
	 }
	 echo ("</ul>");
}
Link to comment
https://forums.phpfreaks.com/topic/286948-counter-issues/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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