PHP问题,高手帮帮忙

if($usertype="teachers"){$sql="SELECTU.user_idASuser_id,U.nomASname,U.prenomASfirstna... if ($usertype = "teachers") {
$sql = "SELECT U.user_id AS user_id,
U.nom AS name,
U.prenom AS firstname,
U.email AS email,
U.officialCode AS officialCode,
U.phoneNumber AS phoneNumber,
U.pictureUri AS pictureUri,
U.creatorId AS creator_id,
U.isCourseCreator,
U.isPlatformAdmin AS isPlatformAdmin
FROM `" . $tbl_mdb_names['user'] . "` AS U
WHERE U.isPlatformAdmin = 0 AND U.isCourseCreator = 1";
echo $sql;
}
if ($usertype = "admin") {
$sql = "SELECT U.user_id AS user_id,
U.nom AS name,
U.prenom AS firstname,
U.email AS email,
U.officialCode AS officialCode,
U.phoneNumber AS phoneNumber,
U.pictureUri AS pictureUri,
U.creatorId AS creator_id,
U.isCourseCreator,
U.isPlatformAdmin AS isPlatformAdmin
FROM `" . $tbl_mdb_names['user'] . "` AS U
WHERE U.isPlatformAdmin = 1";
echo $sql;
}

就是这段代码。不管接受到的值是 admin 还是 teachers.

它都会执行第一个if . elseif 不执行。 怎么办?
展开
 我来答
长发飘飘的和尚4f
2009-04-23 · TA获得超过967个赞
知道小有建树答主
回答量:226
采纳率:0%
帮助的人:296万
展开全部
if ($usertype == "teachers")

if ($usertype == "admin")
=是赋值,==才是判断
pzl7758
2009-04-23 · TA获得超过603个赞
知道小有建树答主
回答量:962
采纳率:100%
帮助的人:628万
展开全部
if ($usertype == "teachers") {
$_whereStr = "WHERE U.isPlatformAdmin = 0 AND U.isCourseCreator = 1";
} else if ($usertype == "admin") {
$_whereStr = "WHERE U.isPlatformAdmin = 1";
}

$sql = "SELECT U.user_id AS user_id,
U.nom AS name,
U.prenom AS firstname,
U.email AS email,
U.officialCode AS officialCode,
U.phoneNumber AS phoneNumber,
U.pictureUri AS pictureUri,
U.creatorId AS creator_id,
U.isCourseCreator,
U.isPlatformAdmin AS isPlatformAdmin
FROM `" . $tbl_mdb_names['user'] . "` AS U
{$_whereStr}";
echo $sql;
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
dufei_itcool
2009-04-23 · 超过26用户采纳过TA的回答
知道答主
回答量:86
采纳率:0%
帮助的人:0
展开全部
$usertype = "admin" 这是赋值,不是判断。应该这样$usertype == "admin"
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式