/** * Return a single course's data or nothing if the course doesn't exist * * @db the MySQL database connection * **/ function get_course($db, $courseID) { $courses = get_user_courses($db); foreach ($courses as $row) { if ($row['courseID'] == $courseID) { return $row; } } }
<?php require_once 'includes/all.php'; if (!is_logged_in()) { header("Location: signin.php"); exit(0); } $db = connect_db(); $user_courses = get_user_courses($db, get_logged_in_user_id()); ?> <!DOCTYPE html> <html> <head> <title> Search Groups | Study Group Finder </title> <?php include 'includes/_head.html'; ?> </head> <body> <?php include 'includes/_nav.php'; ?> <div class="breadcrumbs"> <a href="index.php">Home</a> » Search </div> <div class='row'> <div class='col-md-6'>
if (!is_logged_in()) { header("Location: signin.php"); exit(0); } if (!isset($_GET['id'])) { // um header('Status: 404'); die('missing id'); } $db = connect_db(); $user = get_user($db, $_GET['id']); if (!$user) { header('Status: 404'); die('no such user'); } $courses = get_user_courses($db, $user['id']); $college = null; if ($user['college_id']) { $q = $db->prepare("SELECT * FROM colleges WHERE id=?"); $q->bindValue(1, $user['college_id']); $q->execute(); $college = $q->fetch(); } $is_myself = $user['id'] == get_logged_in_user_id(); $id = $_GET['id']; ?> <!DOCTYPE html> <html> <head> <title><?php echo htmlspecialchars($user['name']);