Im doing a project for my collage (e-learning website with php back-end and bootstrap front-end, something like moodle). I have already created login/register system, add/edit users/courses systems etc. But i've got stuck on displaying only those courses that given user has access to.
courses table users table I was trying to achive this by adding multiple user logins to column in every course (course_students) but first i dont know how to do this and 2nd it feels wrong and complicated , any idea how i can validate that ? Im currently using procedural php, this doesnt have to be super secured and efficient
function coursesMainlist() {
include "connect.php";
if ($result = mysqli_query($conn, "SELECT course_id,course_name,course_catagory FROM courses WHERE course_students = {$_SESSION["userid"]}")) {
while ($row = mysqli_fetch_row($result)) {
echo " <a class='list-group-item list-group-item-action text-muted' href='lekcja.php'>
<div class='row'>
<div class='col col-md-6'><span>{$row[2]}<br><span class='text-dark'>{$row[1]}<br></span></span></div>
</div>
</a>";
}
mysqli_free_result($result);
}
mysqli_close($conn);
}