我有这种格式的图库,我想从数据库中获取图库专辑图片 以下是代码,请帮助我,我在php中尝试这个:
<script type="text/javascript">
var countries=new ddtabcontent("countrytabs")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()
</script>
<!--For tab End-->
<!--<textarea_autoexpand>-->
<script type="text/javascript">
$('#textarea1').autoresize();
$('#textarea2').autoresize({
animate: false,
buffer: 2,
onresize: function() {
$('#message').stop(true, true).hide()
.text('Resized to '+$(this).height())
.fadeIn('slow', function() {
$(this).fadeOut();
});
}
});
</script>
<!--</textarea _End>-->
</div>
</div>
<div class="comment">
<!--Stack 1 -->
<div class="image_stack" style="margin-left: 235px">
<img id="photo1" class="stackphotos" src="images/2.jpg">
<img id="photo2" class="stackphotos" src="images/3.jpg">
<img id="photo3" class="stackphotos" src="images/1.jpg">
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
首先连接数据库。
<?php mysql_connect('{YOUR-HOST-NAME}','{USER-NAME}','{PASSWORD}');
mysql_select_db('YOUR-DATABASE-NAME'?>
连接后从数据库中基本查询图像
<?php
$query = mysql_query("SELECT {YOUR-IMAGE-FIELD-NAME} FROM {YOUR-TABLE-NAME}");
$i = 1;
while ($row = mysql_fetch_array($query)) {
?>
<img id="photo<?php echo $i ?>" class="stackphotos" src="<?php echo $row['YOUR-IMAGE-FIELD-NAME']; ?>">
<?php $i++; } ?>