call image through response id in form

0

I have a form, where at each response the result is stored in the database and presented in a table:

<td> <center> <?php echo date('d/m/Y H:i:s', strtotime($row["data"])); ?> </center> </td>
<td> <center> <?php echo $row["nome"];?></center> </td>
<td> <center> <?php echo $row["img"];?></center> </td>

How do I call a given image by the answer given in the form?

Example: User replied yes to form and table appears in the table x

    
asked by anonymous 18.02.2018 / 19:23

2 answers

0

id is impractical, since each record has a id , if you have 200 records, you hypothetically would have to create 200 images for each one and create more images for the id s next, which makes it unfeasible. But by the content of the question, I believe that is not the intention (only the title supposes this).

What you can do is create an image for each type of response and upload it to the server:

  • sim.png and
  • no.png

When pulling the data from the bank, just check what type of response was given and load the respective image. It would look something like this:

<td> <center> <?php echo date('d/m/Y H:i:s', strtotime($row["data"])); ?> </center> </td>
<td> <center> <?php echo $row["nome"];?></center> </td>
<td> <center> <img src="<?php echo $resposta;?>.png" /></center> </td>

Where the variable $resposta should have the value of " yes " or " no " coming from PHP according to the given answer, name of the image in HTML.

    
18.02.2018 / 22:49
0

I was able to make the call, follow the way: <?php if($row["nometabelaBD"] == 'SIM'){ echo "<img src=\"img.jpg\">";} just made an if there and I solved the problem, but I thank everyone for the comments

    
22.02.2018 / 01:10