Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用cookie获取id,对匹配字段执行内部联接_Php_Sql_Cookies_Inner Join - Fatal编程技术网

Php 使用cookie获取id,对匹配字段执行内部联接

Php 使用cookie获取id,对匹配字段执行内部联接,php,sql,cookies,inner-join,Php,Sql,Cookies,Inner Join,这是我的第一篇帖子,但我发现这个论坛非常有用!我希望你能帮助我 我的难题是:我让用户登录,然后互相打分。一旦用户登录,我希望他们能够看到他们所做的评分(这一个我得到的工作-我可以通过一个表单生成的唯一id选择的评论),还可以看到他们收到的评分摘要。这就是它似乎变得棘手的地方。我尝试了一个内部连接,但没有产生任何结果 现在我有这个部分在我的html上面 <?php include "connect.php"; if(isset($_COOKIE['ID_my_site'])

这是我的第一篇帖子,但我发现这个论坛非常有用!我希望你能帮助我

我的难题是:我让用户登录,然后互相打分。一旦用户登录,我希望他们能够看到他们所做的评分(这一个我得到的工作-我可以通过一个表单生成的唯一id选择的评论),还可以看到他们收到的评分摘要。这就是它似乎变得棘手的地方。我尝试了一个内部连接,但没有产生任何结果

现在我有这个部分在我的html上面

<?php 
    include "connect.php";
    if(isset($_COOKIE['ID_my_site'])) 
    { 
        $username = $_COOKIE['ID_my_site']; 
        $pass = $_COOKIE['Key_my_site']; 
        while($info = mysql_fetch_array( $check ))   
        { 
            //if the cookie has the wrong password, they are taken to the login page 
            if ($pass != $info['password']) 
            {
                header(""); 
            } 
            //otherwise they are shown the admin area    
            else 
            {
                echo ""; 
                echo ""; 
            } 
        } 
    } 
     else 
    //if the cookie does not exist, they are taken to the login screen 
    {            
        header(""); 
    } 
include "settings.php";
?>

这部分在我的html之后

<?php
    include('connect.php');
    $result = mysql_query("SELECT r.user, r.rating1, r.rating2, r.rating3, u.username
                             FROM reviews r INNER JOIN users u ON r.user=u.username
                            WHERE r.user='$userid' ORDER BY r.user DESC") 
                or die(mysql_error()); 

        echo "<table border='1' cellpadding='10'>";
        echo "<tr>
                  <th></th>
                  <th>View Comments</th>
                  <th>Rating 1</th>
                  <th>Rating 2</th>
                  <th>Rating 3</th>
              </tr>";

        while($row = mysql_fetch_array( $result )) {
               echo "<tr>";
               echo '<td><a href="showit.php?id=' . $row['id'] . '">View/Print</a></td>';
               echo '<td>' . $row['rating1'] . '</td>';
               echo '<td>' . $row['rating2'] . '</td>';
               echo '<td>' . $row['rating3'] . '</td>';
               echo "</tr>"; 
        } 
        echo "</table>";
?> 
如果这是第19行:

while($row = mysql_fetch_array( $result )) {
               echo "<tr>";
               echo '<td><a href="showit.php?id=' . $row['id'] . '">View/Print</a></td>';
               echo '<td>' . $row['rating1'] . '</td>';
               echo '<td>' . $row['rating2'] . '</td>';
               echo '<td>' . $row['rating3'] . '</td>';
               echo "</tr>"; 
        } 
while($row=mysql\u fetch\u array($result)){
回声“;
回声';
回显“.$row['rating1']”;
回显“.$row['rating2']”;
回显“.$row['rating3']”;
回声“;
} 

您应该使用数组中值的位置,如1,2,3。。以此类推,不是评级1,评级2。。等等。

谢谢你,约翰!我仍在研究这个问题,看看是否能找到答案。:)我最终放弃了连接,并在感谢页面的cookie中更新了ratings表,然后从review表中调用迭代。谢谢你的回复,约翰尼。我称你为正确的回答者。