从mysql表加载图像

时间:2013-09-23 15:18:31

标签: php mysql

我编写了下面的代码,我可以在一个单独的div中加载一个列的每个图像,有人可以帮我调整代码,以便它打开同一个div中的所有图像吗?

<?php

mysql_connect("localhost","root","");
mysql_select_db("bravo");
$res=mysql_query("select * from coisas");

while ($row=mysql_fetch_array($res)) {

    echo "<div>";?> <img src="<?php echo $row["imagem"]; ?>"> <?php echo "</div>";

}
?>

5 个答案:

答案 0 :(得分:1)

试试这个

<?php

mysql_connect("localhost","root","");
mysql_select_db("bravo");
$res=mysql_query("select * from coisas");
echo "<div>";
while ($row=mysql_fetch_array($res)) {

    echo "<img src=".$row["imagem"].">";

}
echo "</div>";
?>

答案 1 :(得分:0)

<?php

mysql_connect("localhost","root","");
mysql_select_db("bravo");
$res=mysql_query("select * from coisas");

echo "<div>";
while ($row=mysql_fetch_array($res)) { ?>

 <img src="<?php echo $row["imagem"]; ?>"> 
<?php 
}
echo "</div>";
?>

答案 2 :(得分:0)

<?php

    mysql_connect("localhost","root","");
    mysql_select_db("bravo");
    $res=mysql_query("select * from coisas");

?>
<div>
<?php
    while ($row=mysql_fetch_array($res)) {

    echo "<img src=\"{$row['imagem']}\">";

    }
?>
</div>

答案 3 :(得分:0)

echo "<div>";
while ($row=mysql_fetch_array($res)) {
    ?> <img src="<?php echo $row["imagem"]; ?>">

<?php 
}
echo "</div>"; ?>

答案 4 :(得分:0)

<?php

mysql_connect("localhost","root","");
mysql_select_db("bravo");

$res = mysql_query("select * from coisas");

while ($row=mysql_fetch_array($res)):
?>
    <div><img src="<?php echo $row["imagem"]; ?>"></div>;

<?php endwhile; ?>