带有评论类型评论的问题

如何解决带有评论类型评论的问题

| 大家好,我想知道我是否可以在我为一个项目构建的网站上获得一些帮助。它几乎完成了,但是我正在努力进行其中的一部分,这基本上是评论。 我正在创建一个电影评论网站,有点像IMDB.com,但我的课程只适合上课,但是我真的很努力地工作。 对我来说,理想的情况是让某人能够键入他们想要搜索的电影,然后在他们提交后将他们带到另一个页面。在该页面上,电影信息,例如电影名称,描述,类型,等级等。然后在其下,回顾人们对电影的看法。但是,我无法获得的一件事是,当有人键入Avatar时,会出现电影评论,但是当他们键入Ghost Rider时,会出现完全相同的评论,如果可以的话,我希望他们分开。 对于我的桌子, 电影
MovieID,Description,Rating,Genre
评论
ReviewID,Name,Review,MovieID
我在这方面一直处于停滞状态,这有点困扰我,我已经看了很多地方,但仍然找不到我要寻找的东西。 这是我的代码,很遗憾地通知我,我在PHP或编程方面不是很擅长。而且所有这些操作都是在Dreamweaver中完成的,因此,如果看上去很乱,那就是为什么。
<?php require_once(\'../Connections/lesson6.php\'); ?>

<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER[\'PHP_SELF\'].\"?doLogout=true\";
if ((isset($_SERVER[\'QUERY_STRING\'])) && ($_SERVER[\'QUERY_STRING\'] != \"\")){
$logoutAction .=\"&\". htmlentities($_SERVER[\'QUERY_STRING\']);
}

if ((isset($_GET[\'doLogout\'])) &&($_GET[\'doLogout\']==\"true\")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION[\'MM_Username\'] = NULL;
$_SESSION[\'MM_UserGroup\'] = NULL;
$_SESSION[\'PrevUrl\'] = NULL;
unset($_SESSION[\'MM_Username\']);
unset($_SESSION[\'MM_UserGroup\']);
unset($_SESSION[\'PrevUrl\']);

$logoutGoTo = \"index.php\";
if ($logoutGoTo) {
header(\"Location: $logoutGoTo\");
exit;
}
}
?>
<?php require_once(\'../Connections/lesson6.php\'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = \"\";
$MM_donotCheckaccess = \"true\";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers,$strGroups,$UserName,$UserGroup) { 
// For security,start by assuming the visitor is NOT authorized. 
$isValid = False; 

// When a visitor has logged into this site,the Session variable MM_Username set equal      to their username. 
// Therefore,we know that a user is NOT logged in if that Session variable is blank. 
if (!empty($UserName)) { 
// Besides being logged in,you may restrict access to only certain users based on an    ID established when they login. 
// Parse the strings into arrays. 
$arrUsers = Explode(\",\",$strUsers); 
$arrGroups = Explode(\",$strGroups); 
if (in_array($UserName,$arrUsers)) { 
  $isValid = true; 
} 
// Or,you may restrict access to only certain users based on their username. 
if (in_array($UserGroup,$arrGroups)) { 
  $isValid = true; 
} 
if (($strUsers == \"\") && true) { 
  $isValid = true; 
} 
} 
return $isValid; 
}

$MM_restrictGoTo = \"login.php\";
if (!((isset($_SESSION[\'MM_Username\'])) && (isAuthorized(\"\",$MM_authorizedUsers,$_SESSION[\'MM_Username\'],$_SESSION[\'MM_UserGroup\'])))) {   
$MM_qsChar = \"?\";
$MM_referrer = $_SERVER[\'PHP_SELF\'];
if (strpos($MM_restrictGoTo,\"?\")) $MM_qsChar = \"&\";
if (isset($_SERVER[\'QUERY_STRING\']) && strlen($_SERVER[\'QUERY_STRING\']) > 0) 
$MM_referrer .= \"?\" . $_SERVER[\'QUERY_STRING\'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . \"accesscheck=\" .   urlencode($MM_referrer);
header(\"Location: \". $MM_restrictGoTo); 
exit;
}
?>
<?php
if (!function_exists(\"GetSQLValueString\")) {
function GetSQLValueString($theValue,$theType,$theDefinedValue = \"\",$theNotDefinedValue = \"\") 
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists(\"mysql_real_escape_string\") ?   mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case \"text\":
  $theValue = ($theValue != \"\") ? \"\'\" . $theValue . \"\'\" : \"NULL\";
  break;    
case \"long\":
case \"int\":
  $theValue = ($theValue != \"\") ? intval($theValue) : \"NULL\";
  break;
case \"double\":
  $theValue = ($theValue != \"\") ? doubleval($theValue) : \"NULL\";
  break;
case \"date\":
  $theValue = ($theValue != \"\") ? \"\'\" . $theValue . \"\'\" : \"NULL\";
  break;
case \"defined\":
  $theValue = ($theValue != \"\") ? $theDefinedValue : $theNotDefinedValue;
  break;
}
return $theValue;
}
}

if (!function_exists(\"GetSQLValueString\")) {
function GetSQLValueString($theValue,$theNotDefinedValue = \"\") 
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists(\"mysql_real_escape_string\") ?   mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case \"text\":
  $theValue = ($theValue != \"\") ? \"\'\" . $theValue . \"\'\" : \"NULL\";
  break;    
case \"long\":
case \"int\":
  $theValue = ($theValue != \"\") ? intval($theValue) : \"NULL\";
  break;
case \"double\":
  $theValue = ($theValue != \"\") ? doubleval($theValue) : \"NULL\";
  break;
case \"date\":
  $theValue = ($theValue != \"\") ? \"\'\" . $theValue . \"\'\" : \"NULL\";
  break;
case \"defined\":
  $theValue = ($theValue != \"\") ? $theDefinedValue : $theNotDefinedValue;
  break;
}
return $theValue;
}
}

$colname_GetMovie = \"-1\";
if (isset($_GET[\'Search\'])) {
$colname_GetMovie = $_GET[\'Search\'];
}
mysql_select_db($database_lesson6,$lesson6);
$query_GetMovie = sprintf(\"SELECT * FROM movie WHERE MovieName = %s\",GetSQLValueString($colname_GetMovie,\"text\"));
$GetMovie = mysql_query($query_GetMovie,$lesson6) or die(mysql_error());
$row_GetMovie = mysql_fetch_assoc($GetMovie);
$totalRows_GetMovie = mysql_num_rows($GetMovie);

mysql_select_db($database_lesson6,$lesson6);
$current_MovieID=MovieID;
$query_Recordset1 = \"SELECT * FROM reviews WHERE MovieID=$current_MovieID\";
$Recordset1 = mysql_query($query_Recordset1,$lesson6) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
<title>Results</title>
<link href=\"styles/style_sheet.css\" rel=\"stylesheet\" type=\"text/css\" />



<style type=\"text/css\">
a:link {
color: #0F0;
}
a:visited {
color: #0F0;
}
</style>
</head>
<body>

<div id=\"main_container\">
<div id=\"header\">

</div><!--End of header-->
<div class=\"shadow\">
<div id=\"navbar\"><a href=\"index.php\">Home</a> &nbsp;&nbsp;&nbsp; <a     href=\"register.php\">Register</a> &nbsp;&nbsp;&nbsp; <a href=\"login.php\">Login</a> / <a href=\"<?php echo $logoutAction ?>\">Logout</a> &nbsp;&nbsp;&nbsp; <a   href=\"Search.php\">Search</a></div><!--End of NavBar-->
</div><!--End of navbar shadow-->
<br />
<div class=\"shadow\">
<div id=\"Content\">
<h2> Results:</h2>
<?php if ($totalRows_GetMovie == 0) { // Show if recordset empty ?>
<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
Sorry,there was no movie with that name in the database. Click <a   href=\"Search.php\">here</a> to search again.
</form>
<?php } // Show if recordset empty ?>
<p>&nbsp;</p>
<?php if ($totalRows_GetMovie > 0) { // Show if recordset not empty ?>
<form action=\"\" name=\"Movie_Search\"method=\"get\">
<p>Movie Name: <?php echo $row_GetMovie[\'MovieName\']; ?></p>
<p> Movie Description: <?php echo $row_GetMovie[\'Description\']; ?></p>
<p>Genre: <?php echo $row_GetMovie[\'Genre\']; ?></p>
<p>Rating: <?php echo $row_GetMovie[\'Rating\']; ?></p>
<p>&nbsp;</p>
</form>
<?php } // Show if recordset not empty ?>
<label for=\"movie_search\"></label>
<form action=\"\" method=\"get\">
<center><h2>Reviews</h2></center>
<?php do { ?>
<table width=\"566\">
  <tr>
    <td width=\"20\" height=\"97\"><p><img src=\"Pictures/Male-User-icon.png\" width=\"67\"  height=\"67\" /></p></td>
    <td width=\"534\"><p> <?php echo $row_Recordset1[\'Name\']; ?> says:</p>
      <p><?php echo $row_Recordset1[\'Review\']; ?></p>
      <p>-------------------------------------------------------------------------------------------------</p></td>
  </tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form id=\"insert_comments\" s style=\"border:thin\" name=\"insert_comments\"   method=\"POST\"first_name\">
First Name:</label>
<br />
  <input type=\"text\" name=\"first_name\" id=\"first_name\" />
<br>
  <label for=\"desc\">Comments:<br /></label>
<textarea name=\"comments\" id=\"comments\" cols=\"45\" rows=\"5\"></textarea>
</p>
<p>
<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Submit\" />
</p>
</form>

<p>&nbsp;</p>
</div>
<!--End of Contentr-->
</div><!--End of content shadow-->

<div class=\"footer\">

<hr />© Nate Christensen<hr />
</div><!--End of footer-->
</div><!--End of Main Container-->


</body>
</html>
<?php
mysql_free_result($GetMovie);

mysql_free_result($Recordset1);

?>
    

解决方法

评论表包含评论,对不对?我可以看到那里有一个MovieID列,因此您应该能够以条件
WHERE MovieID = \'$current_movie_id\'
查询数据库,以便仅获取特定电影的评论。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-