如何从我的数据库中获取1个值到mysql中的页面(不是mysqli)

时间:2017-01-13 11:41:03

标签: php mysql

如何从我的数据库中获取1个值到mysql中的页面(不是mysqli)

我现在的代码是:

if (controle($username, $password) == true) {
    $resultaat = mysql_query("SELECT priviledged FROM klanten WHERE email='$user'");
    echo $resultaat;
    if($resultaat =2) {

        $_SESSION['user'] = $username;
        $_SESSION['pass'] = $password;
        $_SESSION['rights'] = 2;
        echo "U bent ingelogd! welkom klant";

        header("Refresh:1; URL=geheim.php");
    }
    else if ($resultaat = 1) {
        $_SESSION['user'] = $username;
        $_SESSION['pass'] = $password;
        $_SESSION['rights'] = 1;
        echo "U bent ingelogd! Welkom Ruud.";
        header("Refresh:1; URL=index.php");
    }
} if (controle($username, $password) == true) {
    $resultaat = mysql_query("SELECT priviledged FROM klanten WHERE email='$user'");
    echo $resultaat;
    if($resultaat =2) {

        $_SESSION['user'] = $username;
        $_SESSION['pass'] = $password;
        $_SESSION['rights'] = 2;
        echo "U bent ingelogd! welkom klant";

        header("Refresh:1; URL=geheim.php");
    }
    else if ($resultaat = 1) {
        $_SESSION['user'] = $username;
        $_SESSION['pass'] = $password;
        $_SESSION['rights'] = 1;
        echo "U bent ingelogd! Welkom Ruud.";
        header("Refresh:1; URL=index.php");
    }
}`

我得到$ resultaat的回声结果作为资源ID#8 但我需要$ resultaat给我一个回声,它回馈了'特权'的价值。所以1或2,取决于数据库中的内容。

1 个答案:

答案 0 :(得分:0)

$resultaat = mysql_query("SELECT priviledged FROM klanten WHERE email='$username'");
While($data = mysql_fetch_array($resultaat))
{
   echo $data['priviledged'];
}