Retrieving An Array Of Images On Html Page Using Php
I am retrieving images from a directory using php. Images are displayed on PHP page (getUser.php) but how can these images be display on any HTML. getUser.php
Solution 1:
If I understand your question, you are looking for some template system in php.
Firstly, there is one already in the php. PHP allows you to mix html and php code using tags.
So you can create something like:
<?phpif ($images): ?><?php$counter = 1?><ul><?phpforeach ($imagesas$image): ?><liid="item-<?phpecho$counter++ ?>"><imgsrc="<?phpecho$image['source']?>"></li><?phpendforeach?></ul><?phpendif?>
While it is good practice to separate application logic and html code, pure php is not the best tool for this job. Fortunately, there is plenty of tools on web, for example Smarty or Latte
Solution 2:
Consider the following:
ASP.NET
<img src="images/vimages/<%=row["image"] %>">
PHP
<imgsrc="images/vimages/<?=$row["image"]?>">
Post a Comment for "Retrieving An Array Of Images On Html Page Using Php"