Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 258825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:12:46+00:00 2026-05-11T22:12:46+00:00

I cannot work out how to display an image depending on the vaule of

  • 0

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&nbsp;"; 
   //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 . "&amp;postcode=".$postcode."&amp;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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:12:46+00:00Added an answer on May 11, 2026 at 10:12 pm

    Your question is not quite clear to me but Yours this line of code

    `$r[0] = if ($idd == 1021) echo "IMAGE URL": echo "";`
    

    can be rewritten as

    echo $r[0] = ($idd == 1021) ? "IMAGE URL" : "";
    

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

    $arr = array('1021' => 'img 1', '1022' => 'Img 2')
    

    then you could try something like this

    echo $r[0] = array_key_exists($idd, $data) ? $data[$id] : "";
    

    assuming that you are looping through ID values ($id).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 155k
  • Answers 156k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well what your code is doing is getting the DataGridView… May 12, 2026 at 10:47 am
  • Editorial Team
    Editorial Team added an answer Everything in .NET can be transformed to a string in… May 12, 2026 at 10:47 am
  • Editorial Team
    Editorial Team added an answer You have wrong color settings, you must specify 4 byte… May 12, 2026 at 10:47 am

Related Questions

I have an array of values being made available, but unfortunately some of the
I am using Jörn Zaefferer's jquery autocomplete plugin, and I can't seem to figure
Hey, I'm trying to figure out how to display the ▼ character properly in
I am in the process of porting a Delphi 2006 app to Delphi 2009.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.