echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br />";
How can i embed above PHP code in html. i have image folder in server where i would like to display image.
echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br />";
How can i embed above PHP code in html. i have image folder in server where i would like to display image.
What's the problem?
But your file must be .php and then insert into html.
<?php echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br />"; ?>
You can try this:
<img src="images/<?php print $row['filename'];?>" alt="" /><br />
Try this-
echo "<img src='images". $row['filename']."' alt=''/><br />";
You can embed PHP inside HTML also, you can embed HTML inside your PHP. Both approaches work. But, preferred on is to embed PHP inside HTML. The reason is:
1) PHP parser parses every PHP code.
2) So, if we have written HTML code in PHP, it will parse the code.
3) Hence the load on parser will be more.
4) Where as, HTML tags (codes) as shown directly on the browser (without any parsing)
So always, embedding PHP into HTML is better.
Thanks.