tbl老师
lrn
fname
lname
email
image
schedule
tbl用户
lrn
fname
lname
email
image
account-type
$ id = $ _ SESSION ['id'];
$ get_record_sched = mysqli_query($ db,“从教师INNER JOIN用户上的选择时间表,在Teacher.lrn = users.lrn WHERE Teacher.lrn ='$ id'“中);
我想根据登录帐户的ID回显确切的计划。但是有了这个查询,就没有输出...
答案 0 :(得分:1)
您说您有$id
个会话。假设lrn
列是ID,则
Select t.schedule
From teacher t
Where t.lrn = $id
无需将表与用户表联接。
请注意,建议进行参数绑定。
$statement = $connection->prepare("Select t.schedule From teacher t Where t.lrn = ?");
$statement->bind_param("s", $id);
答案 1 :(得分:0)
在您的条件不正确的地方。他们没有任何参数可以验证条件。所以要这样更改
"SELECT schedule FROM teacher INNER JOIN users ON teacher.id = users.id WHERE 1 "
OR
在连接条件相同的地方使用
"SELECT schedule FROM teacher INNER JOIN users ON teacher.id = users.id AND teacher.schedule = users.id WHERE 1 "
OR
如果您已在会话中记录了已使用的ID,例如
$id=$_SESSION['user_id'];
"SELECT schedule FROM teacher INNER JOIN users ON teacher.id = users.id WHERE teacher.schedule='$id' "