
正文
php滚轮显示数据库数据 php遍历数据库表中内容
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
php如何让数据库中的图片在网页首页滚动显示
可以用无缝图片滚动效果 如php滚轮显示数据库数据:
!DOCTYPE html
html
head
meta charset="utf-8"
title/title
style
* { margin: 0; padding: 0;}
body{ background-color:#1B1B1B}
#div1{ width: 800px; height: 150px; position: relative; margin: 100px auto;overflow: hidden;}
#div1 ul { width: 800px; height: 150px; position: relative; }
#div1 ul li { height: 150px; float: left; list-style: none; padding-right:20px;}
#div1 ul li img { width: 200px; height: 150px; display: inline-block;}
a{ color: #B4B4B4; }
/style
script type="text/javascript"
window.onload=function(){
var odiv = document.getElementById('div1');
var oul = odiv.getElementsByTagName('ul')[0];
var ali = oul.getElementsByTagName('li');
var spa = -2;
oul.innerHTML=oul.innerHTML+oul.innerHTML;
oul.style.width=ali[0].offsetWidth*ali.length+'px';
function move(){
if(oul.offsetLeft-oul.offsetWidth/2){
oul.style.left='0';
}
if(oul.offsetLeft0){
oul.style.left=-oul.offsetWidth/2+'px'
}
oul.style.left=oul.offsetLeft+spa+'px';
}
var timer = setInterval(move,30)
odiv.onmousemove=function(){clearInterval(timer);}
odiv.onmouseout=function(){timer = setInterval(move,30)};
document.getElementsByTagName('a')[0].onclick = function(){
spa=-2;
}
document.getElementsByTagName('a')[1].onclick = function(){
spa=2;
}
}
/script
/head
body
a href="#" style=" display: block; margin:0 auto; width: 50px;"向左走/a
a href="#" style=" display: block; margin:0 auto; width: 50px;"向右走/a
div id="div1"
ul
liimg src="img/1.jpg"//li
liimg src="img/2.jpg"//li
liimg src="img/3.jpg"//li
liimg src="img/4.jpg"//li
/ul
/div
/body
/html
相关问答
Q1: PHP 怎么显示数据库中的数据 求源代码
读数据库,以表格输出的示例代码:
?php
header('Content-type:text/html;charset=utf-8');
$db = new mysqli('localhost','root','root','books');
$rows = $db-query('SELECT * FROM customers');
echo 'table border="1"trtd姓名/tdtd年龄/td/tr';
while($row = $rows-fetch_assoc()){
echo 'trtd'.$row['name'].'/td';
echo 'td'.$row['address'].'/td/tr';
}
?
Q2: PHP数据刷屏显示-如何像机场大屏幕显示航班信息一样显示数据库中的数据
我的思路是:
数据库中新建一个表
is_showUpdate
字段:id、is_update
记录 :id=1;is_update = false;
当你的程序要修改显示信息的时候(也就是展示数据),信息修改完毕将is_showUpdate表的记录标记为true
update is_showUpdate set is_update ='true' where id = 1;
展示页面通过js定时器通过ajax每五秒调取下你的接口,接口只是查询is_showUpdate 表的id为1的记录 is_update 是否为true;如果该字段为true,则此接口将id=1的记录的is_update修改为false,然后给前台页面反水数据,刷新页面;
关于php滚轮显示数据库数据和php遍历数据库表中内容的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。







