Display an image if the value "7" is in the "Code" Row

Asked

Viewed 65 times

0

I appreciate the help you will offer me. I have tried many things, but now I am not moving forward at all. I managed to put this code but it doesn’t show me any picture.

Up on top of me

 $results = $query->fetchAll( PDO::FETCH_ASSOC );

And there on the table it comes like this:

  <?php foreach( $results as $row ){
    if($row['Codigos'] == 7 && $row['Maquinas'] == 5) {
 echo '<img src="/images/'.$photo->t1.png.'"/>';
    }
    ?>

In short... I will have a table with several possibilities, will be 3 columns in the table and the images will change every X minutes and if the value changes in the database, then will change the image inside the table also.

Thank you all again!

  • And what’s the mistake ?

  • var_dump($row['Codigos']) gives what? and var_dump($row['Maquinas']) ?

  • @Thanks for helping out, so... nothing shows up. If I put only view information it appears, but trying to use this code with the image will not...

  • @Isac What values do they bring? Then, there is a gateway installed in a location that brings me information through an IP. These are numbers that update every X minutes. Always numbers...

  • is missing close the foreach

  • Only has a number or has the whole ip separated by . ? It’s like string or how int ? All these kinds of details matter and may make a difference to what you’re trying to do

  • @Isac In fact I have a separate table that brings this information, so I set up a view that brings only the results. In short, then I have a view only for what I need to "pull". If there is the value 2 in the column "x" and the value 3 in the column "y" then shows the image. Gave to understand?

  • If you add any image manually, it appears?

  • @Márciocristian Thanks for help :) Yes, I tried to insert normally and it was... <td class="Tg-031e"><img src="images/TELA-MONITOR-USAR_01.png" alt="></td>

  • If you can, edit and paste an output of the $photo variable, try using var_dump.

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.