一、项目分析
准备先在首页实现动态数据
1、创建数据表
数据表有:栏目表、导航表(这两者本来也可以合并的)、图片表、新闻列表
2、数据查询
查询使用PDO预处理查询
3、代码分段
首页代码分为
index.php
<?php
include 'inc/header.php';
include 'inc/banner.php';
include 'inc/news.php';
include 'inc/images.php';
include 'inc/trade.php';
include 'inc/footer.php';
header.php
<?php
require 'DB.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>网站首页</title>
<!-- <link rel="stylesheet" href="static/css/reset.css">-->
<link rel="stylesheet" href="static/font/iconfont.css">
<link rel="stylesheet" href="static/css/index.css">
</head>
<body>
<!--公共顶部导航区-->
<header>
<?php foreach ($cates as $cate) :?>
<a href=""><?php echo $cate['name']; ?></a>
<?php endforeach; ?>
<span><a href=""><i class="iconfont icon-huiyuan2"></i>登陆</a><a href="">免费注册</a></span>
</header>
<!--logo+搜索框+快捷入口区-->
<div class="logo">
<img src="<?php echo $logo[0]['url']?>" alt="">
<label>
<input type="search">
<a href="" class="iconfont icon-jinduchaxun"></a>
</label>
<span>
<a href="" class="iconfont icon-huiyuan1"></a>
<a href="" class="iconfont icon-danmu"></a>
<a href="" class="iconfont icon-duoxuankuang"></a>
<a href="" class="iconfont icon-jishufuwu"></a>
<a href="" class="iconfont icon-peiwangyindao"></a>
<a href="" class="iconfont icon-wenjianjia"></a>
<a href="" class="iconfont icon-huiyuan1"></a>
</span>
</div>
<!--主导航区-->
<nav>
<div>
<span class="iconfont icon-gongdan"></span>
<span>资讯 <br> 看学</span>
<?php foreach ($navs as $nav) :?>
<a href=""><?php echo $nav['name']; ?></a>
<?php endforeach; ?>
</div>
<div>
<span class="iconfont icon-renwujincheng"></span>
<span>资讯 <br> 看学</span>
<?php foreach ($navs as $nav) :?>
<a href=""><?php echo $nav['name']; ?></a>
<?php endforeach; ?>
</div>
<div>
<span class="iconfont icon-gongdan"></span>
<span>资讯 <br> 看学</span>
<?php foreach ($navs as $nav) :?>
<a href=""><?php echo $nav['name']; ?></a>
<?php endforeach; ?>
</div>
<div>
<span class="iconfont icon-DOC"></span>
<span>资讯 <br> 看学</span>
<?php foreach ($navs as $nav) :?>
<a href=""><?php echo $nav['name']; ?></a>
<?php endforeach; ?>
</div>
</nav>
footer.php
<!--合作网站-->
<div class="title" style="background:#fff">
<span>合作网站</span>
</div>
<div class="my-links">
<a href="https://www.php.cn">php中文网</a>
<a href="https://www.html.cn">html中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.php.cn">php中文网</a>
<a href="https://www.html.cn">html中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.php.cn">php中文网</a>
<a href="https://www.html.cn">html中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.php.cn">php中文网</a>
<a href="https://www.html.cn">html中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.php.cn">php中文网</a>
<a href="https://www.html.cn">html中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.php.cn">php中文网</a>
<a href="https://www.html.cn">html中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.php.cn">php中文网</a>
<a href="https://www.html.cn">html中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.php.cn">php中文网</a>
<a href="https://www.html.cn">html中文网</a>
<a href="https://www.py.cn">python中文网</a>
<a href="https://www.py.cn">python中文网</a>
</div>
<!--页底部-->
<footer>
<div>
<a href="">简介</a>
<a href="">联系我们</a>
<a href="">招聘信息</a>
<a href="">友情链接</a>
<a href="">用户服务协议</a>
<a href="">隐私权声明</a>
<a href="">法律投诉声明</a>
</div>
<div><span>LOGO</span></div>
<div>
<p>2019 fengniao.com. All rights reserved . 安徽闹着玩有限公司(无聊网)版权所有</p>
<p>皖ICP证150110号 京ICP备14323013号-2 皖公网安备110108024357788号</p>
<p>违法和不良信息举报电话: 0551-1234567 举报邮箱: admin@baidu.com</p>
</div>
<div>
<p>关注公众号</p>
<img src="<?=$erwei[0]['url'];?>" alt="">
</div>
</footer>
</body>
</html>
banner.php
<!--轮播图-->
<?php
require 'connect.php';
//获取轮播图片
$sql = "SELECT * FROM `picture` WHERE `name`= 'banner2'";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$banner = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取轮播右边图片
$sql = "SELECT * FROM `picture` WHERE `name`= 'banner-right'";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$banner_right = $stmt ->fetchAll(PDO::FETCH_ASSOC);
?>
<div class="slider">
<img src="<?php echo $banner[0]['url'] ?>" alt="">
<img src="<?php echo $banner_right[0]['url'] ?>" alt="">
</div>
news.php
<!--新闻资讯区-->
<div class="news">
<div class="title">
<a>新闻资讯</a>
<a href="">更多</a>
</div>
<div class="content">
<div class="pic">
<a href=""><img src="<?php echo $n_1[0]['url'] ?>" alt="" class="first-img"></a>
<a href=""><img src="<?php echo $n_2[0]['url'] ?>" alt=""></a>
<a href=""><img src="<?php echo $n_3[0]['url'] ?>" alt=""></a>
<a href="">三星Note10/10+发布 <br> 搭载挖孔前摄</a>
<a href="">小米公布6400万 <br> 和1亿像素手机信息</a>
</div>
<div class="list">
<a href="">性价比广角 腾龙17-28F2.8评测</a>
<ul>
<?php foreach ($news as $new) : ?>
<li><span>[新闻]</span><a href=""><?php echo $new['title'];?></a></li>
<?php endforeach;?>
<?php foreach ($news as $new) : ?>
<li><span>[新闻]</span><a href=""><?php echo $new['title'];?></a></li>
<?php endforeach;?>
<!-- <li><span>[新闻]</span><a href="">Entaniya宣布推出Super 35 PL卡口鱼眼镜头</a></li>
<li><span>[新闻]</span><a href="">轻便灵巧可变形 JOBY入门迷你三脚架套装试用</a></li>
<li><span>[新闻]</span><a href="">乐摄宝Photo Active BP 300 AW背包评测</a></li>
<li><span>[新闻]</span><a href="">佳能注册相机无线充电和眼控对焦专利</a></li>
<li><span>[新闻]</span><a href="">Entaniya宣布推出Super 35 PL卡口鱼眼镜头</a></li>
<li><span>[新闻]</span><a href="">轻便灵巧可变形 JOBY入门迷你三脚架套装试用</a></li>
<li><span>[新闻]</span><a href="">乐摄宝Photo Active BP 300 AW背包评测</a></li>
<li><span>[新闻]</span><a href="">乐摄宝Photo Active BP 300 AW背包评测</a></li> -->
</ul>
</div>
<div class="list">
<a href="">性价比广角 腾龙17-28F2.8评测</a>
<ul>
<?php foreach ($news as $new) : ?>
<li><span>[新闻]</span><a href=""><?php echo $new['title'];?></a></li>
<?php endforeach;?>
<?php foreach ($news as $new) : ?>
<li><span>[新闻]</span><a href=""><?php echo $new['title'];?></a></li>
<?php endforeach;?>
<!-- <li><span>[新闻]</span><a href="">佳能注册相机无线充电和眼控对焦专利</a></li>
<li><span>[新闻]</span><a href="">Entaniya宣布推出Super 35 PL卡口鱼眼镜头</a></li>
<li><span>[新闻]</span><a href="">轻便灵巧可变形 JOBY入门迷你三脚架套装试用</a></li>
<li><span>[新闻]</span><a href="">乐摄宝Photo Active BP 300 AW背包评测</a></li>
<li><span>[新闻]</span><a href="">佳能注册相机无线充电和眼控对焦专利</a></li>
<li><span>[新闻]</span><a href="">Entaniya宣布推出Super 35 PL卡口鱼眼镜头</a></li>
<li><span>[新闻]</span><a href="">轻便灵巧可变形 JOBY入门迷你三脚架套装试用</a></li>
<li><span>[新闻]</span><a href="">乐摄宝Photo Active BP 300 AW背包评测</a></li>
<li><span>[新闻]</span><a href="">乐摄宝Photo Active BP 300 AW背包评测</a></li> -->
</ul>
</div>
</div>
</div>
images.php
<!--二手交易专区-->
<div class="title">
<span>二手交易</span>
</div>
<div class="second-hand">
<div>
<a href="">抢好货</a>
<span>0低价, 便捷,安全,快速</span>
</div>
<div>
<span>热门分类</span>
<a href="">美女写真</a>
<a href="">日本美女</a>
<a href="">美国美女</a>
<a href="">国内美女</a>
<a href="">AV美女</a>
</div>
<?php foreach ($shop1 as $s1) : ?>
<a href=""><img src="<?php echo $s1['url']; ?>" alt="" width="176" height="122"></a>
<?php endforeach; ?>
<!-- <a href=""><img src="static/images/shop/shop1.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop2.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop3.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop4.jpg" alt="" width="176" height="120"></a> -->
<?php foreach ($shop1 as $s1) : ?>
<div class="detail">
<a href=""><?php echo $s1['title']; ?></a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<?php endforeach; ?>
<!-- <div class="detail">
<a href=""><?php echo $s1['title']; ?></a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海报墙面贴画艺术装画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海饰画酒吧卧室贴画图画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海饰画酒吧卧室贴画图画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div> -->
<?php foreach ($shop2 as $s2) : ?>
<a href=""><img src="<?php echo $s2['url']; ?>" alt="" width="176" height="122"></a>
<?php endforeach; ?>
<!-- <a href=""><img src="static/images/shop/shop1.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop2.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop3.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop4.jpg" alt="" width="176" height="120"></a> -->
<?php foreach ($shop1 as $s1) : ?>
<div class="detail">
<a href=""><?php echo $s1['title']; ?></a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<?php endforeach; ?>
<!-- <a href=""><img src="static/images/shop/shop5.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop6.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop7.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop8.jpg" alt="" width="176" height="120"></a>
<div class="detail">
<a href="">美女性感写真海报墙艺术装饰画贴画图画</a><br>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海报墙面贴画艺术装画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海饰画酒吧卧室贴画图画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海饰画酒吧卧室贴画图画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div> -->
<div>
<?php foreach ($ads as $ad) : ?>
<a href=""><img src="<?php echo $ad['url']; ?>" alt="" width="180" height="112"></a>
<?php endforeach; ?>
<!-- <a href=""><img src="<?php echo $ad['url']; ?>" alt="" width="180" height="112"></a>
<a href=""><img src="static/images/ad/2.png" alt="" width="180" height="112"></a>
<a href=""><img src="static/images/ad/3.png" alt="" width="180" height="112"></a>
<a href=""><img src="static/images/ad/4.png" alt="" width="180" height="112"></a>
<a href=""><img src="static/images/ad/image.png" alt="" width="393" height="56"></a>
<a href=""><img src="static/images/ad/ad2.jpg" alt="" width="393" height="56"></a> -->
<?php foreach ($ads2 as $ad2) : ?>
<a href=""><img src="<?php echo $ad2['url']; ?>" alt="" width="393" height="56"></a>
<?php endforeach; ?>
</div>
</div>
trade.php
<!--二手交易专区-->
<div class="title">
<span>二手交易</span>
</div>
<div class="second-hand">
<div>
<a href="">抢好货</a>
<span>0低价, 便捷,安全,快速</span>
</div>
<div>
<span>热门分类</span>
<a href="">美女写真</a>
<a href="">日本美女</a>
<a href="">美国美女</a>
<a href="">国内美女</a>
<a href="">AV美女</a>
</div>
<?php foreach ($shop1 as $s1) : ?>
<a href=""><img src="<?php echo $s1['url']; ?>" alt="" width="176" height="122"></a>
<?php endforeach; ?>
<!-- <a href=""><img src="static/images/shop/shop1.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop2.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop3.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop4.jpg" alt="" width="176" height="120"></a> -->
<?php foreach ($shop1 as $s1) : ?>
<div class="detail">
<a href=""><?php echo $s1['title']; ?></a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<?php endforeach; ?>
<!-- <div class="detail">
<a href=""><?php echo $s1['title']; ?></a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海报墙面贴画艺术装画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海饰画酒吧卧室贴画图画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海饰画酒吧卧室贴画图画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div> -->
<?php foreach ($shop2 as $s2) : ?>
<a href=""><img src="<?php echo $s2['url']; ?>" alt="" width="176" height="122"></a>
<?php endforeach; ?>
<!-- <a href=""><img src="static/images/shop/shop1.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop2.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop3.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop4.jpg" alt="" width="176" height="120"></a> -->
<?php foreach ($shop1 as $s1) : ?>
<div class="detail">
<a href=""><?php echo $s1['title']; ?></a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<?php endforeach; ?>
<!-- <a href=""><img src="static/images/shop/shop5.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop6.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop7.jpg" alt="" width="176" height="120"></a>
<a href=""><img src="static/images/shop/shop8.jpg" alt="" width="176" height="120"></a>
<div class="detail">
<a href="">美女性感写真海报墙艺术装饰画贴画图画</a><br>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海报墙面贴画艺术装画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海饰画酒吧卧室贴画图画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div>
<div class="detail">
<a href="">美女性感写真海饰画酒吧卧室贴画图画</a>
<div>
<a href="">
<span>¥ 333</span>
<span>美女</span>
</a>
</div>
</div> -->
<div>
<?php foreach ($ads as $ad) : ?>
<a href=""><img src="<?php echo $ad['url']; ?>" alt="" width="180" height="112"></a>
<?php endforeach; ?>
<!-- <a href=""><img src="<?php echo $ad['url']; ?>" alt="" width="180" height="112"></a>
<a href=""><img src="static/images/ad/2.png" alt="" width="180" height="112"></a>
<a href=""><img src="static/images/ad/3.png" alt="" width="180" height="112"></a>
<a href=""><img src="static/images/ad/4.png" alt="" width="180" height="112"></a>
<a href=""><img src="static/images/ad/image.png" alt="" width="393" height="56"></a>
<a href=""><img src="static/images/ad/ad2.jpg" alt="" width="393" height="56"></a> -->
<?php foreach ($ads2 as $ad2) : ?>
<a href=""><img src="<?php echo $ad2['url']; ?>" alt="" width="393" height="56"></a>
<?php endforeach; ?>
</div>
</div>
数据库连接文件:connect.php
<?php
//数据库连接配置
$dbParams = [
‘type’ => ‘mysql’,
‘host’ => ‘127.0.0.1’,
‘dbname’ => ‘shop’,
‘username’=> ‘root’,
‘password’=> ‘111’
];
//配置数据源dsn
$dsn = "{$dbParams['type']}:host={$dbParams['host']};dbname={$dbParams['dbname']}";
try {
//连接数据库
$pdo = new PDO($dsn,$dbParams['username'],$dbParams['password']);
} catch (PDOException $e) {
//连接失败返回信息
die('Connection Failed' .$e->getMessage());
}
数据库查询软件:DB.php
<?php
include __DIR__ .'/connect.php';
$sql = "SELECT * FROM `picture` WHERE `name`= 'LOGO'";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$logo = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取栏目信息
$sql = 'SELECT `id`,`name` FROM `category`';
$stmt = $pdo->prepare($sql);
$stmt->execute();
$cates = $stmt->fetchAll(PDO::FETCH_ASSOC);
//var_dump($cates);
$cate_count = count($cates); // 栏目数量
//$title = $cates->title;
//获取导航信息
$sql = 'SELECT `id`,`name` FROM `nav`';
$stmt = $pdo->prepare($sql);
$stmt->execute();
$navs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$navs_count = count($navs); // 栏目数量
//获取新闻图片1
$sql = "SELECT * FROM `picture` WHERE `name`= 'n-1'";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$n_1 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取新闻图片2
$sql = "SELECT * FROM `picture` WHERE `name`= 'n-2'";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$n_2 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取新闻图片3
$sql = "SELECT * FROM `picture` WHERE `name`= 'n-3'";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$n_3 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取新闻区标题列表
$sql = "SELECT * FROM `news`";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$news = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取图片列表
$sql = "SELECT * FROM `picture` WHERE `id` > 11 LIMIT 2";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$pictures1 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
for ($i=0; $i < count($pictures1) ; $i++) {
$url1[] = $pictures1[$i]['url'];
$title1[] = $pictures1[$i]['title'];
}
//获取出售图片
$sql = "SELECT * FROM `picture` WHERE `id` > 19 LIMIT 4";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$shop1 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取出售图片
$sql = "SELECT * FROM `picture` WHERE `id` > 23 LIMIT 4";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$shop2 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取广告图片
$sql = "SELECT * FROM `picture` WHERE `id` > 29 LIMIT 4";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$ads = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取广告图片
$sql = "SELECT * FROM `picture` WHERE `id` > 33 LIMIT 2";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$ads2 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//获取二维码
$sql = "SELECT * FROM `picture` WHERE `name` = 'erwei-code'";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$erwei = $stmt ->fetchAll(PDO::FETCH_ASSOC);
//var_dump($erwei);
//echo $erwei[0]['url'];
//var_dump($url1,$title1);
/*$url1 = [];
$title1 = [];
foreach ($pictures1 as $p1) {
for ($i=0; $i < count($pictures1); $i++) {
$url1[] = $p1[$i]['url'];
$title1[] = $p1[$i]['title1'];
}
}
var_dump($url1,$pictures2);*/
$sql = "SELECT * FROM `picture` WHERE `id` > 13 LIMIT 2";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$pictures2 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
for ($i=0; $i < count($pictures2) ; $i++) {
$url2[] = $pictures2[$i]['url'];
$title2[] = $pictures2[$i]['title'];
}
/*foreach ($pictures2 as $p2) {
$url2[] = $p2['url'];
$title1[] = $p2['title1'];
}*/
$sql = "SELECT * FROM `picture` WHERE `id` > 15 LIMIT 2";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$pictures2 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
for ($i=0; $i < count($pictures2) ; $i++) {
$url3[] = $pictures2[$i]['url'];
$title3[] = $pictures2[$i]['title'];
}
$sql = "SELECT * FROM `picture` WHERE `id` > 17 LIMIT 2";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$pictures2 = $stmt ->fetchAll(PDO::FETCH_ASSOC);
for ($i=0; $i < count($pictures2) ; $i++) {
$url4[] = $pictures2[$i]['url'];
$title4[] = $pictures2[$i]['title'];
}
//var_dump($news);
?>
4、结果
二、总结
1、关于项目分析
没有任何经验,不知道分析什么
2、关于数据的使用
数据库查询后返回的结果类型不是很清楚,不知道返回的是一维数组还是二维数组,在遍历的时候遇到了很大的问题
3、关于单条记录查询
想查到一个指定记录不知道用什么办法,感觉用的是最LOW的查询办法
4、关于URL跳转
超级链接,网页跳来跳去的,一会儿就把自己搞晕了,不知道有什么好的办法