伙计们,
上学时,我需要建立一个可以玩Flash游戏的网站,
通过以文本形式留下的反应和使用数字系统的投票系统来对游戏进行评分(即1 =非常差而10 =非常好)。
现在我要做的是:
每个游戏类别都有一个索引页面,用户可以在其中单击游戏名称,然后将其定向到脚本加载游戏的另一个页面。
到目前为止,我已经为索引(母版)页面编写了此代码。
<!DOCTYPE html>
<?php
include("dbconnect.php");
?>
<html>
<head>
<meta charset="UTF-8">
<title>Master page</title>
</head>
<body>
<?php
//Place all data from this mySQL query in $result.
$result = mysql_query("SELECT * FROM gamesDB");
//While a row of data exists, put that row in $data as an associative array.
while($data = mysql_fetch_assoc($result)) {
//Echo a link to all the games in the MySQL database.
echo "<a href='detail.php?id=" . $data['ID'] . "'>";
//Echo the games name in the url.
echo $data['Spel'];
//Echo the closing tags
echo "</a>";
echo "<br />";
}
?>
</body>
</html>
这是针对游戏(详细)页面的。
<!DOCTYPE html>
<?php
include("dbconnect.php");
?>
<html>
<head>
<meta charset="UTF-8">
<title>Detail page</title>
</head>
<body>
<?php
//Place all data out of the database, with the ID number retrieved out of the url into $result.
$result = mysql_query("SELECT * FROM gamesDB WHERE id = '" . $_GET['id'] . "'");
//While a row of data exists, put that row in $data as an associative array.
while($data = mysql_fetch_assoc($result)) {
//Retrieve the files name from the database and place it in the <embed> tags as src="...".
echo "<embed width='800' height='512' src='" . $data['file'] . "' type='application/x-shockwave-flash'></embed>";
//Echo the games name
echo "Spel: " . $data['Spel'] . "<br />";
//Echo the points (not yet functional)
echo "Punten: " . $data['Punten'] . "<br />";
//Echo all reactions from users regarding this game.
echo "Reacties: " . $data['Reactie'] . "<br />";
}
?>
</body>
</html>
当我单击母版页上的链接时,我被重定向到详细信息页面,但不幸的是,游戏无法加载。
在我的MySQL数据库中,我将文件名添加到ID为1的第一行。 )“电影未加载...”。
有人可以帮我这个忙吗?我的思维方式可能偏离了方向,还是朝着正确的方向前进。
由于这是学校的一项任务,因此无需担心任何SQL注入漏洞。
谢谢!
最佳答案
我实际上忘了在文件列中输入一个条目。
既然我已经解决了"<embed>"
的问题,我想集中精力介绍如何在“评论”列中添加用户评论,并显示每个评论。我想自己找到尽可能多的代码,这样您就可以用指针对我的问题做出反应,而不用编写完整的代码,我将不胜感激。