Use a PHP variable to dynamically display an image in HTML

137
February 27, 2018, at 07:03 AM

I'm trying to use a variable in a .php file to choose img src. Here's my attempt:

<?php echo "<img src=\"$ICON\">"; ?> or <img src="<?php echo $ICON; ?>"/>

Neither have worked, is there anything obviously wrong? There's nothing displaying, not even the code, when I render the page.

Any guidance would be much appreciated, especially a correct implementation of the above. Sorry for poor code, only looked at these languages since yesterday.

Rent Charter Buses Company
READ ALSO
PHP name an un-named multidimensional associative array

PHP name an un-named multidimensional associative array

How can I change ['visits'][0] to a name: 'location_1', ['visits'][1] to: 'location_2', etc?

139
preg_match in loop returning impossible results

preg_match in loop returning impossible results

I'm sure I'm missing somethingI know just enough to be dangerous

138
PHP - Is this code guaranteed to stop if the condition isn&#39;t met?

PHP - Is this code guaranteed to stop if the condition isn't met?

I am only learning Exceptions and error reporting, and I am trying to understand behaviours of try/catch and perhaps other methods that I don't know yetI have code like this:

118
CRUD operation. Edit won&#39;t work. Can&#39;t display data to form [PHP]

CRUD operation. Edit won't work. Can't display data to form [PHP]

I been making a CRUD functions for my practice websiteI was able to display data from my database and also have a delete functions

151