2

I need to display an <img> element in a Bootgrid data table. I'm getting the data from the response into PHP as follows:

$name = $key->name; 
$region = $key->region->name;
$flag = $key->region->flagUrl;

Then I loop through it to create the table.

This works:

<tr>
    <td><?php echo $name ?></td>
    <td><?php echo $region ?></td>
    <td><?php echo $flag ?></td>
    <!-- DISPLAYS THE URL STRING -->
</tr>

This doesn't work:

<tr>
    <td><?php echo $name ?></td>
    <td><?php echo $region ?></td>
    <td><img src="<?php echo $flag ?>" alt="<?php echo $region ?>" ></td> 
    <!-- DISPLAYS EMPTY TD -->
</tr>

Any way I can make the image display?

Thank you.

Cristian
  • 33
  • 5
  • Have you outputted the variables, such as `var_dump($flag)` to make sure it's not null? – Rob W Jul 15 '15 at 15:43
  • Yes. I can echo the flag URL on the page as a string, just not inside the src attribute of an image tag. This is not a matter of PHP, but one of jQuery Bootgrid replacing the contents of cells on doc ready. I changed the question tags, so now it's filed under jQuery. Thank you. – Cristian Jul 15 '15 at 15:57
  • You may want to also post your JS source as well.. to see what you're currently using. – Rob W Jul 15 '15 at 20:10
  • Have you solved it? You should use formatters for that, if you did solve, post it as an answer for the community. – Bruno Vaz Oct 20 '15 at 01:52

0 Answers0