diff --git a/website/public/styles/menu.css b/website/public/styles/menu.css index 6cdae65..4d4b8bb 100644 --- a/website/public/styles/menu.css +++ b/website/public/styles/menu.css @@ -30,7 +30,7 @@ cursor: pointer; } -.friend-item:hover { +.friend-item:hover, .group-item:hover { background: #845663; color: white; } diff --git a/website/queries/user.php b/website/queries/user.php index 3c7287a..97ddbc2 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -170,4 +170,30 @@ function changeUserStatusByID($id, $status) { } -?> +function selectRandomNotFriendUser($userID) { + $stmt = $GLOBALS["db"]->prepare(" + SELECT + `user`.`username` + FROM + `user` + WHERE + `userID` NOT IN (SELECT + `user1ID` + FROM + `friendship` + WHERE `user1ID` = :userID) OR + `userID` NOT IN (SELECT + `user2ID` + FROM + `friendship` + WHERE `user2ID` = :userID) + ORDER BY + RAND() + LIMIT + 1 + "); + + $stmt->bindParam(':userID', $userID, PDO::PARAM_INT); + $stmt->execute(); + return $stmt->fetch(); +} \ No newline at end of file diff --git a/website/views/head.php b/website/views/head.php index d9a985a..bb6eec4 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -15,7 +15,8 @@ "; } + + $randomUser = selectRandomNotFriendUser($_SESSION["userID"])["username"]; + + echo " +
  • +
    + +
    +
  • + "; if ($i > 1) { $i -= 1; echo " -
  • - En nog $i anderen... -
  • "; +
  • + En nog $i anderen... +
  • + "; } + ?> @@ -87,17 +106,28 @@ // Echo the friend. echo " - -
  • -
    - PF - $name -
    -
  • -
    +
  • +
    + +
    +
  • "; } - if ($i > 3) { + + if ($i == 0) { + echo "
  • +
    + Je hoort nergens bij. +
    +
  • "; + } else if ($i > 3) { $i -= 3; echo "