html - PHP: Echo IMG tag with two different ID -


i need print written 2 img tag different id use only 1 line echo code?

example:

$sql = mysql_query("select * products order pid");  while ($data = mysql_fetch_array($sql)){  echo "<div class=\"item\">\n";  echo "<div>";  echo "<img src=\"img/products/".$data['photo']."\" />";  echo "</div>";  echo "</div>\n"; } 

output:

<div class="item"> <div> <img src="img/products/1.png" /> <img src="img/products/2.png" /> </div> </div> 

you need move outer html outside loop. way printed once while image tag printed each row. example:

$sql = mysql_query("select * products order pid"); echo "<div class=\"item\">\n"; echo "<div>"; while ($data = mysql_fetch_array($sql)){  echo "<img src=\"img/products/".$data['photo']."\" />"; } echo "</div>"; echo "</div>\n"; 

output:

<div class="item"> <div> <img src="img/products/1.png" /> <img src="img/products/2.png" /> </div> </div> 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -