php文章添加评论功能
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第一步:添加数据库,库名为:hf
第二步:在目录下加入以下php网页:showprocess.php,
内容为:
<?php
require_once('../Connections/connMain.php');
$id = $_REQUEST['main_id'];
$comment = $_REQUEST['textfield2']; //评论内容
<td width="587" class="STYLE15">
<label>
<textarea name="textfield2" cols="80" rows="6" class="STYLE15"></textarea>
</label>
</td>
</tr>
</table>
<p align="center" class="STYLE15" type="submit">
$sql = "select por_id,main_id,name,c_time,nr from `hf` where main_id='$main_id' order by c_time desc";
//$sql这里可以根据你想要的进行改动比如只有会员才可以看得到
$record = mysql_query($sql);
</form>
</table>
第四步:添加评论显示区:
------------效果为:--------------
---------代码为:---------------
<table id="table1" width="700" border="0" align="center">
<tr>
<td><p align="left"><span class="STYLE19"><strong>☆</strong>评论区<strong>☆</strong></span>
<tr>
<td width="80" height="32" valign="top"><div align="right" class="STYLE15">评论者:</div></td>
<td width="454" valign="top"><div align="left"><input name="textfield" type="text" class="STYLE15" >
<label>
<input type="submit" name="Submit1" value="提交" onclick="return confirm('请仔细检查留言内容,提交后将无法修改!');"
>
</label>
</p>
<p align="center"> </p></td>
</tr>
$username = $_REQUEST['textfield']; //评论人名称
if($username == '')
{
$username = '匿名';
}
$Sql = "INSERT INTO hf(main_id,nr,name,c_time)
VALUES('$id','$comment','$username',now())";
</div>
</label>
</td>
-->
</tr>
</table></td>
</tr>
<tr><input type="hidden" name="main_id" value="<?php echo $_GET['main_id'];?>">
<td width="106" height="81" class="STYLE15"><div align="right"><span class="STYLE15">评论内容:</span> </div></td>
-------Leabharlann Baidu-----代码如下:--------
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="form1" method="post" action="showprocess.php">
</div>
</td>
<!--
<td width="10%" valign="top"><div align="left">评论时间:</div></td>
<td width="50%" valign="bottom">
<label>
<div align="left">
<input type="text" name="textfield3">
<tr>
<td height="87"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="21" colspan="2" class="STYLE15"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
mysql_query($Sql);
echo '<meta http-equiv=refresh content="0;URL=jyxcshowdetail.php?main_id=' . $id . '">';
?>
第三部:添加新闻页面的评论留言区:
-----------效果为:-------------
$RecordCount = mysql_num_rows($record);
$PageSize = 5;//设置每页显示几条
$PageCount = ceil($RecordCount/$PageSize);
<p align="left">
<?php
//por_id(评论表id)main_id(新闻id)name(评论者)c_time(时间)nr(评论内容)
$n_id=$_GET['main_id'];
/*$n_id=14;//新闻id*/
$db = mysql_select_db("hf");
mysql_query("set names gbk");
第二步:在目录下加入以下php网页:showprocess.php,
内容为:
<?php
require_once('../Connections/connMain.php');
$id = $_REQUEST['main_id'];
$comment = $_REQUEST['textfield2']; //评论内容
<td width="587" class="STYLE15">
<label>
<textarea name="textfield2" cols="80" rows="6" class="STYLE15"></textarea>
</label>
</td>
</tr>
</table>
<p align="center" class="STYLE15" type="submit">
$sql = "select por_id,main_id,name,c_time,nr from `hf` where main_id='$main_id' order by c_time desc";
//$sql这里可以根据你想要的进行改动比如只有会员才可以看得到
$record = mysql_query($sql);
</form>
</table>
第四步:添加评论显示区:
------------效果为:--------------
---------代码为:---------------
<table id="table1" width="700" border="0" align="center">
<tr>
<td><p align="left"><span class="STYLE19"><strong>☆</strong>评论区<strong>☆</strong></span>
<tr>
<td width="80" height="32" valign="top"><div align="right" class="STYLE15">评论者:</div></td>
<td width="454" valign="top"><div align="left"><input name="textfield" type="text" class="STYLE15" >
<label>
<input type="submit" name="Submit1" value="提交" onclick="return confirm('请仔细检查留言内容,提交后将无法修改!');"
>
</label>
</p>
<p align="center"> </p></td>
</tr>
$username = $_REQUEST['textfield']; //评论人名称
if($username == '')
{
$username = '匿名';
}
$Sql = "INSERT INTO hf(main_id,nr,name,c_time)
VALUES('$id','$comment','$username',now())";
</div>
</label>
</td>
-->
</tr>
</table></td>
</tr>
<tr><input type="hidden" name="main_id" value="<?php echo $_GET['main_id'];?>">
<td width="106" height="81" class="STYLE15"><div align="right"><span class="STYLE15">评论内容:</span> </div></td>
-------Leabharlann Baidu-----代码如下:--------
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="form1" method="post" action="showprocess.php">
</div>
</td>
<!--
<td width="10%" valign="top"><div align="left">评论时间:</div></td>
<td width="50%" valign="bottom">
<label>
<div align="left">
<input type="text" name="textfield3">
<tr>
<td height="87"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="21" colspan="2" class="STYLE15"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
mysql_query($Sql);
echo '<meta http-equiv=refresh content="0;URL=jyxcshowdetail.php?main_id=' . $id . '">';
?>
第三部:添加新闻页面的评论留言区:
-----------效果为:-------------
$RecordCount = mysql_num_rows($record);
$PageSize = 5;//设置每页显示几条
$PageCount = ceil($RecordCount/$PageSize);
<p align="left">
<?php
//por_id(评论表id)main_id(新闻id)name(评论者)c_time(时间)nr(评论内容)
$n_id=$_GET['main_id'];
/*$n_id=14;//新闻id*/
$db = mysql_select_db("hf");
mysql_query("set names gbk");