php - 如何使用 php、mysql、css 和 html 制作动态幻灯片?

标签 php html mysql css

我想用 CSS 和 HTML 制作动态幻灯片。图像将由 tb_image 中的 id 获取。

id int
image_name varchar (100)
image_path (100)

如何使用php、mysql、css和html制作动态幻灯片? 还是可以通过id获取图片?

include "connnection.php";
$result = mysql_query("select * from slider");
?> 
    <div class="accordian">
    <?php 
        $i=1;
    while($row = mysql_fetch_array($result)){
    ?>
            <ul>
                <li>
                    <div class="image_title">
                    </div>
                    <a href="#">
                    <img src="../img/<?php echo $i;?>.jpg" alt="" width="640" border="320"/> //I tried use this codes but it's error

                    </a>
                </li>

                <li>
                    <div class="image_title">
                        <a href="#">Slide 2</a>
                    </div>
                    <a href="#">
                        <img src="img/<?php echo $_GET['id']=2;?>.jpg" alt="" width="640" border="320"/>
                    </a>
                </li>
                <li>
                    <div class="image_title">
                        <a href="#">Slide 3</a>
                    </div>
                    <a href="#">
                        <img src="img/3.jpg"/>
                    </a>
                </li>
                <li>
                    <div class="image_title">
                        <a href="#">Slide 4</a>
                    </div>
                    <a href="#">
                        <img src="img/4.jpg"/>
                    </a>
                </li>
                <li>
                    <div class="image_title">
                        <a href="#">Slide 5</a>
                    </div>
                    <a href="#">
                        <img src="img/5.jpg"/>
                    </a>
                </li>
            </ul>
            <?php } ?>

最佳答案

不知道您从查询中得到了什么,这是一个猜测:

替换您的任何 <img>

<img src="../img/<?php echo $row['id']?>.jpg" alt="" width="640" border="320"/>

要“调试”您的数据,您可以将 while 循环替换为

while($row = mysql_fetch_array($result)){
  print_r($row);
}

这将打印出每行中找到的所有数据。

您可能还想替换已弃用的 mysql_*功能 mysqliPDO .

关于php - 如何使用 php、mysql、css 和 html 制作动态幻灯片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29254886/

相关文章:

html 三个元素在同一行

mysql - 如何使 'datetime' 列正确排序?

mysql - 如何对每个表进行分组计数并按列打印?

php - 使用php脚本将mysql数据输出到csv/txt文件

javascript - 将底部变量值获取到页面顶部

php - CodeIgniter activerecord,检索最后一个插入ID?

jQuery实现多个背景图片淡入淡出

css - 需要 CSS 帮助 - 在多种分辨率下水平绝对定位 DIV(偏离中心)

MYSQL:查找连续计数的开始和结束时间戳

php - filter_var 或自定义函数用于 php 中的电子邮件验证