<?php
// Error reporting:
error_reporting(E_ALL^E_NOTICE);
require "connect.php";
require "banner.class.php";
$bannerResult = mysql_query("SELECT * FROM banners");
$banners = array();
while($row=mysql_fetch_assoc($bannerResult))
{
$banners[] = new Banner($row);
}
// Randomizing the $banners array:
shuffle($banners);
// Splitting the banners array into smaller arrays with 4 banners each:
$bannerGroups = array_chunk($banners,4);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Banner Rotator With PHP, jQuery & MySQL | Tutorialzine demo</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<h1>Simple Banner Rotator With PHP, jQuery & MySQL</h1>
<h2><a href="http://tutorialzine.com/2010/04/simple-banner-rotator-with-php-jquery-mysql/">Go Back to the Tutorial »</a></h2>
<div id="main">
<!-- Two groups of banners -->
<ul class="bannerHolder">
<?php
// Looping through the first group:
foreach($bannerGroups[0] as $ban)
{
echo '<li>'.$ban->html().'</li>';
}
?>
</ul>
<ul class="bannerHolder">
<?php
// Looping through the second group:
foreach($bannerGroups[1] as $ban)
{
echo '<li>'.$ban->html().'</li>';
}
?>
</ul>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一个PHP+MYSQL完成的Ajax图片展示特效,类似于图片提示效果,同时它还可以随机载入图片、打乱排列顺序的功能,你每次刷新网页,得到的图片顺序都是不一样的,而且当把鼠标放到图片上的时候,会动画展现出提示文字,本例中用到了一个封装的Js类,在Script.js中,对学习Ajax技术很有帮助。
资源推荐
资源详情
资源评论
收起资源包目录
SimpleBannerRotator.zip (14个子文件)
SimpleBannerRotator
demo.php 2KB
banner.class.php 680B
img
banners
themeLayouts.gif 5KB
themeForest.gif 10KB
siteGrinder.jpg 7KB
psd2html.jpg 10KB
bestDesigns.jpg 8KB
mailChimp.jpg 17KB
gomedia.jpg 5KB
rapidHTML.png 28KB
connect.php 316B
table.sql 1KB
styles.css 2KB
script.js 876B
共 14 条
- 1
资源评论
DNCS高级工程师
- 粉丝: 761
- 资源: 551
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功