Merge branch 'lars-algemeen' into 'master'

Lars algemeen

See merge request !79
This commit was merged in pull request #83.
This commit is contained in:
Lars van Hijfte
2017-01-20 12:54:24 +01:00
4 changed files with 73 additions and 16 deletions

View File

@@ -30,7 +30,7 @@
cursor: pointer; cursor: pointer;
} }
.friend-item:hover { .friend-item:hover, .group-item:hover {
background: #845663; background: #845663;
color: white; color: white;
} }

View File

@@ -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();
}

View File

@@ -15,7 +15,8 @@
</style> </style>
<?php <?php
include_once("../queries/connect.php"); require_once ("../queries/checkInput.php");
require_once ("../queries/connect.php");
session_start(); session_start();

View File

@@ -7,7 +7,8 @@
<?php <?php
// Load file. // Load file.
include_once("../queries/friendship.php"); require_once("../queries/friendship.php");
require_once("../queries/user.php");
// Get all the friends of a user. // Get all the friends of a user.
$friends = selectAllFriends($_SESSION["userID"]); $friends = selectAllFriends($_SESSION["userID"]);
@@ -45,13 +46,31 @@
</li> </li>
"; ";
} }
$randomUser = selectRandomNotFriendUser($_SESSION["userID"])["username"];
echo "
<li class='friend-item'>
<form action='profile.php' method='get'>
<button type='submit'
name='username'
value='$randomUser'>
<div class='friend'>
Klik hier voor een nieuw vriendje :)
</div>
</button>
</form>
</li>
";
if ($i > 1) { if ($i > 1) {
$i -= 1; $i -= 1;
echo " echo "
<li class='more-item' id='more-friends-click'> <li class='more-item' id='more-friends-click'>
En nog $i anderen... En nog $i anderen...
</li>"; </li>
";
} }
?> ?>
</ul> </ul>
</section> </section>
@@ -87,17 +106,28 @@
// Echo the friend. // Echo the friend.
echo " echo "
<a href='#' class='$extraItem'>
<li class='group-item'> <li class='group-item'>
<form action='group.php' method='get'>
<button type='submit'
name='groupname'
value='$name'>
<div class='group'> <div class='group'>
<img alt='PF' class='group-picture' src='$picture'/> <img alt='PF' class='group-picture' src='$picture'/>
$name $name
</div> </div>
</button>
</form>
</li> </li>
</a>
"; ";
} }
if ($i > 3) {
if ($i == 0) {
echo "<li class='group-item'>
<div class='group'>
Je hoort nergens bij.
</div>
</li>";
} else if ($i > 3) {
$i -= 3; $i -= 3;
echo " echo "
<li class='more-item' id='more-groups-click'> <li class='more-item' id='more-groups-click'>