使用评级系统创建(简单)Flash游戏网站

时间:2015-10-22 14:10:13

标签: php mysql

他们,

对于学校我需要建立一个可以玩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注入漏洞。

谢谢!

1 个答案:

答案 0 :(得分:0)

我实际上忘了在文件列中输入一个条目。 既然我已经解决了"<embed>"的问题,我想重点关注如何将用户评论添加到我的“评论”列,并显示每条评论。我想尽可能多地找到代码,这样你就可以用指针对我的问题做出反应,而不是编写完整的代码,我将非常感激。

相关问题