I cannot work out how to display an image depending on the vaule of a product($idd):
foreach ($response['products'] as $product)
{
if($filter != "all" && $bb[$product['product-id']['value']] && $bb[$product['product-id']['value']][0] != $filter) continue;
$r = array(); $idd = 0; $ca = 0;
foreach($product as $key=>$value)
{
if($key == "product-id")
{
$idd = (int)$value['value'];
$r[0] = $idd?"<input type='radio' name='product_id' value='" . $idd . "'/>":"0 ";
//price//
$r[4] = $bb[$idd]?$bb[$idd][3]:"ID";
//info//
$r[5] = "<a href='checker/info.php?id=" .$idd. "'; rel=\"shadowbox;width=400;height=200\" class=\"option\"'><img src=\"http://www.flipconnect.co.uk/images/more-info.gif\" style=\"border:none; padding-top:24px;\" alt=\"more information about this pack\" /></a>";
//buy
$r[6] = "<a href='checker/next.php?id=" . $idd . "&postcode=".$postcode."&speed=".$phone."'><img src=\"http://www.flipconnect.co.uk/images/buy-now.gif\" style=\"border:none\" alt=\"buy this package\" /></a>";
}
I’m thinking it should tak the form of:
$r[0] = if ($idd == 1021) echo "IMAGE URL": echo "";
But doesn’t work, by the way all the $idd are stored in an array with a load of othewr info.
Your question is not quite clear to me but Yours this line of code
can be rewritten as
Try it.
EDIT
Regarding Bifter’s comment
“This work, how would adapt to display a different image if the $idd value is different. i.e – $idd == 1021 – Image 1 is displayed $idd == 1022 – Image 2 is displayed $idd == 1023 – Image 3 is displayed”
if your data array is something like ..
then you could try something like this
assuming that you are looping through ID values ($id).