Blogger Information
Blog 23
fans 0
comment 0
visits 19933
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
增加评论展示功能2019-09-20
风吹的博客
Original
697 people have browsed it

首先,增加一个pinlun.php的文件用来保存已有评论,并组成数组形成,其次在详情页面增加文本域与提交按钮,pinlin.php循环输出即可

这是pinlun.php

实例

<?php
$pinluns=[

    [
		'mov_id'=>1,
		'cate_id'=>1,
		'name'=>'用户1235:',
		'neirong'=>'和想象不一样'
		
			
	],
	[
		'mov_id'=>1,
		'cate_id'=>1,
		'name'=>'用户4564:',
		'neirong'=>'剧情蛮好'
			
	]
];


?>

运行实例 »

点击 "运行实例" 按钮查看在线实例

这是detail.php

实例

<?php
// 加载公共头部
include __DIR__ . '/header.php';
//加载评论文件
include __DIR__. '/pinlun.php';


	$mov_id = intval($_GET['mov_id']);

	foreach ($movies as $movie) {
		if ($movie['mov_id'] === $mov_id) {
			echo "<h3>{$movie['name']}</h3>";
			echo '<img src="static/images/'.$movie['image'].'" alt="" width="300">';
			echo "<p style='text-indent: 2em'>{$movie['detail']}</p>";
			
		
		}
	};
	        echo "请输入评论";
            echo '<br>';
	        echo "<textarea>";
			echo"</textarea>";
			echo "<button>提交</button>";
			echo '<br>';
			echo "用户评论:";
			echo'<hr>';

    foreach ($pinluns as $pinlun) {
	
		if($pinlun['mov_id']===$mov_id){
			
			echo $pinlun['name'];
			echo '<br>';
			echo $pinlun['neirong'];
			echo '<hr>';
	}


	
};

    


// 加载公共底部
include __DIR__ . '/footer.php';

运行实例 »

点击 "运行实例" 按钮查看在线实例

效果图:

评论.png

做得很简单,没有添加很多样式

Correction status:qualified

Teacher's comments:看上去还可以
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments