對不起,我只是PHP MySQL的初學者,並且遇到了我想要的條件問題。
我取使用SQL值$ _SESSION這是錯誤,看起來像它不能獲取價值。
這是我在我的上面部分代碼:
<?php
session_start();
include_once 'dbconnect.php';
if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM accounts WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
?>
這裏是我的代碼,如果其他條件在我頂吧,雖然它得到「agentFname」和「agentLname '來自數據庫的值,但它無法獲得值'user_type'是來自數據庫的列。
<img src="images/img.jpg" alt="">
<?php
if($_SESSION['user_type'] == 'Team Leader')
{
echo "Team Leader, ".' '.$userRow['agentFname'].' '.$userRow['agentLname'];
}
else
{
echo "Agent, ".' '.$userRow['agentFname'].' '.$userRow['agentLname'];
}
?>
<span class=" fa fa-angle-down"></span>
這是錯誤的輸出,這Edmhar拉瓦格是管理型
謝謝。對於刪除
你在哪裏設置'$ _SESSION ['user_type']'? –
你在哪裏設置這個會話var'$ _SESSION ['user_type']'?? –
您沒有設置** $ _ SESSION ['user_type'] **的值** –