Correction status:Uncorrected
Teacher's comments:
总结:
1、把数据分别放在一个数据库的三张表中,
2、用三个查询语句把数据赋给三个数组中;
3、利用模板制作网站
<?php require 'connect.php'; $sql = 'SELECT * FROM `system` LIMIT 1'; $stmt = $pdo->prepare($sql); $stmt->execute(); $system = $stmt->fetch(PDO::FETCH_ASSOC); $sql = 'SELECT `cate_id`,`name`,`alias` FROM `category`'; $stmt = $pdo->prepare($sql); $stmt->execute(); $cates = $stmt->fetchAll(PDO::FETCH_ASSOC); $cate_count = count($cates); $sql = 'SELECT `mov_id`,`name`,`image`, `detail`, `cate_id` FROM `movies`'; $stmt = $pdo->prepare($sql); $stmt->execute(); $movies = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="public/static/css/style.css"> <meta name="description" content="<?php echo $system['desc'] ?>"> <meta name="keywords" content="<?php echo $system['key'] ?>"> <title><?php echo $system['title'] ?></title> </head> <body> <!--头部导航--> <div class="header"> <ul class="nav"> <li><a href="index.php">首页</a></li> <?php foreach ($cates as $cate) : ?> <li><a href="list.php?cate_id=<?php echo $cate['cate_id']; ?>"><?php echo $cate['alias'] ?></a></li> <?php endforeach; ?> </ul> </div>
点击 "运行实例" 按钮查看在线实例