Jump to content

[SOLVED] Issue with displaying Thumbnails?


divadiva

Recommended Posts

Experts,

 

The code I am working on at the moment uses thumbnails.Issue is that after 15 images it doesnt display anything.Is there a way to put batches or just restructure the code in a way so that all images should be displayed?

 

Here is the code I am working on:

 

<%

include('functions.inc');
opendb();
$feat = mysql_query("SELECT * FROM `inventory` WHERE `featured`=1");

if(mysql_num_rows($feat)) {
while( $a_row = mysql_fetch_array($feat) ) {
	$orig = '../files/' . $a_row['image1'] ;

	print  '<br><b>' . $a_row['inventory_id'] . ' - ' . $a_row['tool_id'] . '</b><br>';

	if( $a_row['image1'] && file_exists($orig) ) {

		print  'Original: ' . str_replace('../files/','',$orig) . '<br>';
		$thmb = str_replace('.jpg','_th.jpg',$orig);
		$thmb = str_replace('.jpeg','_th.jpeg',$thmb);
		$thmb = str_replace('.JPG','_th.JPG',$thmb);
		$thmb = str_replace('.JPEG','_th.JPEG',$thmb);

		if(!file_exists($thmb)) {
			print  'Making: ' . str_replace('../files/','',$thmb) . '<br>';
			// make new
			$thumbHeight = 120 ;		
			$sourceImage = imagecreatefromjpeg("$orig");
			$sourceWidth = imagesx($sourceImage);
			$sourceHeight = imagesy($sourceImage);
			$thumbWidth = floor( $thumbHeight * $sourceWidth / $sourceHeight ) ;
			$targetImage = imagecreatetruecolor($thumbWidth,$thumbHeight);
			imagecopyresampled($targetImage,$sourceImage,0,0,0,0,$thumbWidth,$thumbHeight,$sourceWidth,$sourceHeight);
			imagejpeg($targetImage, "$thmb", 75);
			// @chmod("$thmb", 0777);
		}
		else {
			print  'Exists: ' . str_replace('../files/','',$thmb) . '<br>';
		}
		%>
		<IMG SRC="<%= $thmb ; %>"><br>
		<%
	}
	else {
		print 'No image file found<br>';
	}
}
}


%>



 

 

 

Thankyou in advance.

Link to comment
https://forums.phpfreaks.com/topic/143806-solved-issue-with-displaying-thumbnails/
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.