Marijn button #99

Merged
11166932 merged 152 commits from marijn-button into master 2017-01-23 13:25:08 +01:00
4 changed files with 73 additions and 16 deletions
Showing only changes of commit 28578adb11 - Show all commits

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'>
<div class='group'> <button type='submit'
<img alt='PF' class='group-picture' src='$picture'/> name='groupname'
$name value='$name'>
</div> <div class='group'>
</li> <img alt='PF' class='group-picture' src='$picture'/>
</a> $name
</div>
</button>
</form>
</li>
"; ";
} }
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'>