Blogger Information
Blog 16
fans 0
comment 0
visits 13534
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
把影视详情页面,增加评论展示功能
琥珀的博客
Original
1131 people have browsed it

运行效果:

                1.gif



评论数组列表:header.php中创建数组comments


实例

$comments = [
		['comment_id'=>1, 'comment_content'=>'这片子不错', 'comment_belonger'=>'张三'],
		['comment_id'=>1, 'comment_content'=>'哈哈哈哈哈哈哈哈哈哈哈', 'comment_belonger'=>'李四'],
		['comment_id'=>1, 'comment_content'=>'希望翻拍续集', 'comment_belonger'=>'王五'],
		['comment_id'=>4, 'comment_content'=>'呵呵', 'comment_belonger'=>'张三'],
		['comment_id'=>4, 'comment_content'=>'啊阿阿阿阿阿阿', 'comment_belonger'=>'李四'],
		['comment_id'=>4, 'comment_content'=>'嘿嘿嘿嘿', 'comment_belonger'=>'王五'],
	];

运行实例 »

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


评论列表:在详情页下方加入评论,foreach遍历评论,comment_id和网页跳转的get的mov_id值做匹配,输出对应的                            comment_content和comment_belonger                                          

实例

echo "<h3>热门评论</h3>";
	foreach($comments as $comment){
		if($mov_id==$comment['comment_id']){
		echo "<h4>{$comment['comment_belonger']}:</h4>";		
		echo "{$comment['comment_content']}";			
		echo '<br>';
		echo '<br>';
		echo '<br>';		
		}
	};
	
	if(isset($_POST['belonger'])){
		echo "<h4>{$_POST['belonger']}</h4>";
	}	
	
	if(isset($_POST['content'])){
		echo $_POST['content'];
	}	
	echo '<br>';
	echo '<br>';
	echo '<br>';

运行实例 »

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


增加评论:用post传标签的值到本页面,isset判断是否接受到$_post['']值,点击按钮提交当有值时输出。


实例

echo "<h3>热门评论</h3>";
	foreach($comments as $comment){
		if($mov_id==$comment['comment_id']){
		echo "<h4>{$comment['comment_belonger']}:</h4>";		
		echo "{$comment['comment_content']}";			
		echo '<br>';
		echo '<br>';
		echo '<br>';		
		}
	};
	
	if(isset($_POST['belonger'])){
		echo "<h4>{$_POST['belonger']}</h4>";
	}	
	
	if(isset($_POST['content'])){
		echo $_POST['content'];
	}	
	echo '<br>';
	echo '<br>';
	echo '<br>';

运行实例 »

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





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
Author's latest blog post