我正在制作一个用户管理系统我想做的是当用户登录时他看不到(例如销售员工)他看不到其他部门的链接,我想做的很简单,但我没有知道为什么它不起作用,我的代码是:
$departmentidquery = mysql_query("SELECT department_id FROM users WHERE username = '".$username."'");
$departmnetid = mysql_fetch_row ($departmentidquery);
<ul>
<li><a href="logout.php">Logout.</a></li>
<li <?php if ($departmnetid[0]!=1){?>style="display:none"<?php } ?>> <a href="admin.php">Admin Pgae</a> </li>
<li <?php if ($departmnetid[0]!=2){?>style="display:none"<?php } ?>> <a href="sales.php">sales Pgae</a> </li>
<li <?php if ($departmnetid[0]!=3){?>style="display:none"<?php } ?>> <a href="tech.php">Tech Pgae</a> </li>
</ul>
错误是:
SCREAM: Error suppression ignored for
( ! ) Notice: Undefined variable: departmnetid in C:\wamp\www\Ticket.sys\index.php on line 49
SCREAM: Error suppression ignored for
( ! ) Notice: Undefined variable: departmnetid in C:\wamp\www\Ticket.sys\index.php on line 50
SCREAM: Error suppression ignored for
( ! ) Notice: Undefined variable: departmnetid in C:\wamp\www\Ticket.sys\index.php on line 51
我确信从查询中,我已经尝试了display:none
with的技巧<div>
及其工作,有没有更好的方法来做到这一点?