【问题标题】:How to fetch images from database in Image gallery [closed]如何从图像库中的数据库中获取图像[关闭]
【发布时间】:2013-03-26 05:09:24
【问题描述】:

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

【问题讨论】:

  • 您好,您的数据库查询在哪里?
  • 你的 PHP 在哪里?

标签: php jquery phpmyadmin


【解决方案1】:

先连接数据库。

<?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++; } ?>

【讨论】:

    猜你喜欢
    • 2011-10-28
    • 2014-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-14
    相关资源
    最近更新 更多