I'm using the following code to query a database for image values up to 25 thumbnail images. I am relying on CURL to return a 200 code to find out if the image exists. If not I want to end the thumbnails.
My problem is that it is fetching the images but leaving blank thumbnails if not all 25 images are found. I want to NOT forma the
<?
$image = "<div class='wrap_img_small'><br>";
$ListingRid = $row['matrix_unique_id'];
$img_cnt = 1;
for ($c=1;$c<25;$c++) {
$c_ext = $c;
$ch = curl_init("http://www.domain.com/feeds/fort/rets_images/{$ListingRid}_{$c_ext}.jpg");
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($retcode == '200')
$image .= "<a href=http://www.domain.com/feeds/fort/rets_images/{$ListingRid}_{$c_ext}.jpg rel=\"enlargeimage\" rev=\"targetdiv:loadarea,trigger:click\" title=\"\"><img src=http://www.domain.com/feeds/fort/rets_images/{$ListingRid}_{$c_ext}.jpg title='' width='100' height='75' border='0' /></a>";
else
$c=31;
$img_cnt++;
}
?>
intso you can check against200instead of'200'. And why do you set your counter$cto31if one image isn't found?break;statement after yourelseclause.