把影视网站,数据全部从 数据库中读取
实例
<?php // 加载公共头部 include 'connect.php'; $sql = 'SELECT * FROM detail'; $stmt = $pdo->prepare($sql); if ($stmt->execute()){ $detail = $stmt -> fetchALL(); } include __DIR__ . '/header.php'; $mov_id = intval($_GET['mov_id']); // 复制list.php模板直接修改 foreach ($movies as $movie) { // 1.1用 print_r($movie); 查看下有值没 // 1.2暂停 exit; // 3.0打印下看值一样不 // 3.1var_dump($movie['mov_id']); // 3.2查询两个值和类型是否一样。只要值一样就行。类型不需要 var_dump($mov_id); // 3.3暂停exit; if ($movie['mov_id'] == $mov_id) { // 4.1删除一个= 值一样即可 // 2.1 echo 111; 2. 查询这里数据进来没有 // 2.2 exit; 暂停 echo "<h3>{$movie['name']}</h3>"; echo '<img src="../9192/static/images/'.$movie['image'].'" alt="" width="300">'; echo "<p style='text-indent: 2em'>{$movie['detail']}</p>"; } }; $arr = [ 'biaoti' => '全部评论', 'date' => '2019.08.17 17:55:32', 'pinglun' => [ 'name' => '张三', 'neirong' => '这种爱情也只有电视中才会出现' ] ]; ?> <form> <table> <th style="float: left"><?php echo $arr['biaoti'] ?></th> <tbody> <tr> <td style="padding: 5px 10px"> <?php echo $arr['date']; ?> </td> <br> </tr> <tr> <td style="padding: 5px 10px"> <?php echo $arr['pinglun']['name']; ?> : <?php echo $arr['pinglun']['neirong']; ?></td> <br> </tr> <tr> <td style="padding: 5px 10px"> <textarea class="txt-commit" replyid="0"></textarea></td> </tr> <td> <button style="float: right">发表评论</button> </td> <tbody> </table> </form> <?php // 加载公共底部 include __DIR__ . '/footer.php'; ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例