Friends
prepare("SELECT * FROM friends WHERE userId1 = :id;");
$stmtc->bindParam(':id', $userID, PDO::PARAM_INT);
$stmtc->execute();
$stmt = $GLOBALS['dbcon']->prepare("SELECT * FROM friends WHERE userId1 = :id ORDER BY id DESC LIMIT 8;");
$stmt->bindParam(':id', $userID, PDO::PARAM_INT);
$stmt->execute();
if ($stmt->rowCount() == 0) {
echo 'This user has no friends.';
}else{
echo '
';
}
echo '';
foreach($stmt as $result) {
$userId = $result['userId2'];
$stmt = $GLOBALS['dbcon']->prepare("SELECT username, imgTime, lastSeen, id FROM users WHERE id = :id");
$stmt->bindParam(':id', $userId, PDO::PARAM_INT);
$stmt->execute();
$resultuser = $stmt->fetch(PDO::FETCH_ASSOC);
$username = $resultuser['username'];
if (strlen($username) > 10) {
$username = substr($username, 0, 7) . '...';
}
echo '
';
}
if ($stmt->rowCount() > 0) {
echo '
';
}
if ($stmtc->rowCount() > 8) {
echo '
Show all friends';
}
?>