我正在为一所basci学校建立一个学生门户网站。在门户网站中,学生应该能够访问他们的成绩,课程,课程材料,导师的信息 并查看他们的付款细节以及他们欠学校的费用。
我有mysql表(总共8个表),其中包含与其STUDENT ID相关联的各种关系。
我希望每个学生都能够使用用户名和密码登录 - 我的脚本已经有一个用户表,用于存储用户名和密码凭证。
以下是我的问题:
注意事项:
唯一的问题是如何查询关系表,以便每个注册用户仅查看他或她的信息。信息是根据用户查看的。
如果有人能指出我正确的方向,我们将不胜感激。谢谢。
答案 0 :(得分:0)
首先你不要问这样的问题,所以你不会被投票和阻止现在让我帮忙随时联系我并upvote请我也是新的,并阅读更多关于查询数据库你可能不会很幸运下次
//lets say showstudentsrecordpage.php after they are logged in, you use a cookie a session up to you get their auto incremented ids from database when they log in and query any table you want to with that id
//create a table so you can show that user info after query
<table>
<th>sTUDENT NAME</th>
<th>sTUDENT rrecord</th>
<th>sTUDENT subject</th>
// showstudentsrecordpage.php
$studentcookieafterloggedin = $_COOKIE['userid']; //userid of student who logged in successfully
$studentcookieafterloggedin = mysqli_escape_string($con, $studentcookieafterloggedin);
$bringtheirrecordout = "SELECT FROM mayberecordstable WHERE id= '$studentcookieafterloggedin'";
$runthequery = mysqli_query($con, $bringtheirrecordout);
//variable $con is your connection parameters
if (mysqli_num_rows($runthequery) < 1){
Do what you want here if that user id is not found probably a redirect or something anything you want
}
//you dont need a while loop since it is only one record for a student if it is multiple records for different students then while loop is needed
$fetcharray = mysqli_fetch_array($runthequery);
//this are my own parameters just change it to your own database values
$id = $fetcharray['id'];
$studentname = $fetcharray['studentname'];
$studentgrades = $fetcharray['studentgrades'];
$subjects = $fetcharray['subjects'];'
then show it
<div>
//continue your table for it here
<tr>
<td><?php echo $studentname ?></td>
<td><?php echo $studentgrades ?></td>
<td><?php echo $subjects ?></td>
</tr>
</table>
</div>