为什么在同一页面上显示多个配置文件?

时间:2017-06-22 17:33:45

标签: php mysql

在我的用户个人资料页面中,我设置了个人资料图片系统,当多个用户登录时,该网站会在一个页面上显示所有个人资料图片,而不是单个会话的单个图片。告诉我我做错了什么?提前谢谢。

PROFILE.PHP:

<?php
session_start();
include 'dbh.php';
?>


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Yahbang</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header class="header_profile">
    <nav>
        <ul>

        </ul>
    </nav>
    <form class="logout" action='include/logout.inc.php'>
        <button>Log out</button>
        </form>
</header>

<?php


    $sql = "SELECT * FROM user";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
        $email = $row['email'];
        $sqlImg = "SELECT * FROM profileImg WHERE email='$email'";
        $resultImg = mysqli_query($conn, $sqlImg);
        while ($rowImg = mysqli_fetch_assoc($resultImg)) {
            echo "<div class='userProfileImage'>";               
                if ($rowImg['status'] == 0 ) {
                    echo "<img src='images/profile".$id.".jpg'>";
                } else {
                    echo "<img src='images/profile_default.jpg'>";
                }
                echo "<p>".$row['first']."</p>";
            echo "</div>";
        }
    }   
}       else {
            echo "There are no users yet!";
        }



    if (isset($_SESSION['id'])) {
        echo "<form action='include/uploadProfile.inc.php' method='POST' enctype='multipart/form-data'>
<input type='file' name='file'>
<button type='submit' name='submit'>UPLOAD</button>
    </form>";
    } else {
        header("Location: ../index.php");
    }
?>






<footer class="footer_profile">
    <nav>
        <ul>

        </ul>
    </nav>
</footer>
</body>
</html>

2 个答案:

答案 0 :(得分:0)

注意你的SQL命令

source

在最后添加$ set -a && source .env.development && set +a && ./script.py ('VAR0 is:', 'some""" value0') ,例如- (void)configureCameraForHighestFrameRate:(AVCaptureDevice *)device { AVCaptureDeviceFormat *bestFormat = nil; AVFrameRateRange *bestFrameRateRange = nil; for ( AVCaptureDeviceFormat *format in [device formats] ) { for ( AVFrameRateRange *range in format.videoSupportedFrameRateRanges ) { if ( range.maxFrameRate > bestFrameRateRange.maxFrameRate ) { bestFormat = format; bestFrameRateRange = range; } } } if ( bestFormat ) { if ( [device lockForConfiguration:NULL] == YES ) { device.activeFormat = bestFormat; device.activeVideoMinFrameDuration = bestFrameRateRange.minFrameDuration; device.activeVideoMaxFrameDuration = bestFrameRateRange.minFrameDuration; [device unlockForConfiguration]; } } } ,而不只是第一个结果。 如果您编写SQL,则可以指定结果:

$sql = "SELECT * FROM user";

看一下SQL语句

答案 1 :(得分:0)

您的个人资料页面网址是否与此类似?

profilepage.php?ID = 5

如果没有,您可能想要添加它,因为这样您就可以轻松编辑第一个查询

$sql = "SELECT * FROM user";

并执行类似

的操作
$id= $_GET['id'];
$sql = "SELECT * FROM user WHERE id='$id'";

您可以在配置文件的其余部分继续使用该逻辑,否则,您将从用户表中循环遍历ALL。