Fixed queries and profile page.
This commit is contained in:
@@ -46,12 +46,12 @@ if(empty($_GET["username"])) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$userID = getUserID($db, $_GET["username"]);
|
$userID = getUserID($_GET["username"]);
|
||||||
|
|
||||||
$user = selectUser($db, $userID);
|
$user = selectUser($userID);
|
||||||
$friends = selectAllFriends($db, $userID);
|
$profile_friends = selectAllFriends($userID);
|
||||||
$groups = selectAllUserGroups($db, $userID);
|
$profile_groups = selectAllUserGroups($userID);
|
||||||
$posts = selectAllUserPosts($db, $userID);
|
$posts = selectAllUserPosts($userID);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require("connect.php");
|
require("connect.php");
|
||||||
|
|
||||||
function selectAllFriends($db, $userID) {
|
function selectAllFriends($userID) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
`username`,
|
`username`,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
require("connect.php");
|
require("connect.php");
|
||||||
|
|
||||||
function getUserID($db, $username) {
|
function getUserID($username) {
|
||||||
$stmt = $db->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
`userID`
|
`userID`
|
||||||
FROM
|
FROM
|
||||||
@@ -16,8 +16,8 @@ function getUserID($db, $username) {
|
|||||||
return $stmt->fetch()["userID"];
|
return $stmt->fetch()["userID"];
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectUser($db, $userID) {
|
function selectUser($userID) {
|
||||||
$stmt = $db->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
`username`,
|
`username`,
|
||||||
IFNULL(
|
IFNULL(
|
||||||
@@ -41,7 +41,7 @@ function selectUser($db, $userID) {
|
|||||||
return $stmt->fetch();
|
return $stmt->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAllUserGroups($db, $userID) {
|
function selectAllUserGroups($userID) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
`group_page`.`groupID`,
|
`group_page`.`groupID`,
|
||||||
@@ -64,7 +64,7 @@ function selectAllUserGroups($db, $userID) {
|
|||||||
return $stmt;
|
return $stmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAllUserPosts($db, $userID) {
|
function selectAllUserPosts($userID) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
`postID`,
|
`postID`,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
$_SESSION["userID"] = 2;
|
$_SESSION["userID"] = 2;
|
||||||
|
|
||||||
// Get all the friends of a user.
|
// Get all the friends of a user.
|
||||||
$friends = selectAllFriends($db, $_SESSION["userID"]);
|
$friends = selectAllFriends($_SESSION["userID"]);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
// Print all the users.
|
// Print all the users.
|
||||||
|
|||||||
@@ -4,18 +4,19 @@
|
|||||||
<div class="profile-button">
|
<div class="profile-button">
|
||||||
<p><img src="img/add-friend.png"> Als vriend toevoegen</p>
|
<p><img src="img/add-friend.png"> Als vriend toevoegen</p>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="profile-username"><?php echo $user["username"] ?></h1>
|
<h1 class="profile-username"><?= $user["fname"]?> <?=$user["lname"]?> (<?=$user["username"]?>)</h1>
|
||||||
<p><?php echo $user["bio"] ?></p>
|
<p><?=$user["bio"]?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item-box left platform">
|
<div class="item-box left platform">
|
||||||
<h2>Vrienden</h2>
|
<h2>Vrienden</h2>
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
while($friend = $friends->fetch()) {
|
while($friend = $profile_friends->fetch()) {
|
||||||
echo "<a href='#' data-title='" . $friend["username"] . "'><img class='profile-picture' src='" . $friend["profilepicture"] . "' alt='" . $friend["username"] . "'s profielfoto></a>";
|
echo "<a href='#' data-title='${friend["username"]}'><img class='profile-picture' src='${friend["profilepicture"]}' alt='${friend["username"]}'s profielfoto></a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($friends->rowCount() === 0) {
|
if($friends->rowCount() === 0) {
|
||||||
echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>";
|
echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>";
|
||||||
}
|
}
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
<h2>Groepen</h2>
|
<h2>Groepen</h2>
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
while($group = $groups->fetch()) {
|
while($group = $profile_groups->fetch()) {
|
||||||
echo "<a href='#' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
|
echo "<a href='#' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,3 +53,4 @@
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user