-3

我有这种格式的画廊,我想从数据库中获取画廊相册图像以下是代码,请帮助我,我正在 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>
4

1 回答 1

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++; } ?>
于 2013-04-04T08:30:15.890 回答