Hi,
I have a feed that displays really well, but now I don't want to show the IMAGEURL for every record in the array? I would like to display the IMAGEURL of the first record (or one of the others).
Can this be done?
My current code is below:
<?php
$count = 0;
foreach ($records as $record) {
echo '<div id="full_description">';
echo '<img src="'.$record["IMAGEURL"].'" class="full_description" height="180" width="180">';
echo '<h4><a href="'.$record["PRODUCTURL"].'" target="_blank">'.$record["NAME"].', '.$record["ADDITIONAL/FIELD@1-VALUE"].' ('.$record["ADDITIONAL/FIELD-VALUE"].')</a></h4>';
echo $record["DESCRIPTION"].'<p>Type accommodatie: '. $record["ADDITIONAL/FIELD@2-VALUE"].'<p>';
echo '<strong>Vanaf '.$record["PRICE"].''.$record["PRICE-CURRENCY"].' p.p.</strong> (o.b.v. '.$record["ADDITIONAL/FIELD@3-VALUE"].' pers.)';
echo '</div>';
$count++;
if ($count == 20) break;
}
?>
Thanks in advance!
Kind regards,
Jasper Metselaar
Hello Jasper,
The easiest way to do this based on your code is to use a $first variable, and only display the image if $first is TRUE. For example:
<?php
$count = 0;
$first = TRUE;
foreach ($records as $record) {
echo '<div id="full_description">';
if ($first)
{
echo '<img src="'.$record["IMAGEURL"].'" class="full_description" height="180" width="180">';
$first = FALSE;
}
echo '<h4><a href="'.$record["PRODUCTURL"].'" target="_blank">'.$record["NAME"].', '.$record["ADDITIONAL/FIELD@1-VALUE"].' ('.$record["ADDITIONAL/FIELD-VALUE"].')</a></h4>';
echo $record["DESCRIPTION"].'<p>Type accommodatie: '. $record["ADDITIONAL/FIELD@2-VALUE"].'<p>';
echo '<strong>Vanaf '.$record["PRICE"].''.$record["PRICE-CURRENCY"].' p.p.</strong> (o.b.v. '.$record["ADDITIONAL/FIELD@3-VALUE"].' pers.)';
echo '</div>';
$count++;
if ($count == 20) break;
}
?>
Hope this helps!
Cheers,
David.