Marijn button #99
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
$servername = "agile136.science.uva.nl";
|
|
||||||
$username = "mhbp";
|
|
||||||
$password = "qdtboXhCHJyL2szC";
|
|
||||||
|
|
||||||
// Create connection
|
|
||||||
$conn = new mysqli($servername, $username, $password);
|
|
||||||
|
|
||||||
// Check connection
|
|
||||||
if ($conn->connect_error) {
|
|
||||||
die("Connection failed: " . $conn->connect_error);
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
7
website/mysql_config.xml
Normal file
7
website/mysql_config.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0'?>
|
||||||
|
<MySQL_INIT>
|
||||||
|
<mysql_host>localhost</mysql_host>
|
||||||
|
<mysql_database>myhyvesbookplus</mysql_database>
|
||||||
|
<mysql_username>mhbp</mysql_username>
|
||||||
|
<mysql_password>qdtboXhCHJyL2szC</mysql_password>
|
||||||
|
</MySQL_INIT>
|
||||||
18
website/public/template_sql.php
Normal file
18
website/public/template_sql.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// database gegevens zijn elders opgeslagen
|
||||||
|
include_once("../queries/connect.php");
|
||||||
|
include_once("../queries/friendship.php");
|
||||||
|
|
||||||
|
$friends = selectAllFriends($db, 666);
|
||||||
|
while($friend = $friends->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
echo $friend['username'].' '.$friend['onlinestatus'] . "<br />";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
13
website/queries/connect.php
Normal file
13
website/queries/connect.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$dbconf = simplexml_load_file("/var/mysql_config.xml");
|
||||||
|
if ($dbconf === FALSE) {
|
||||||
|
die("Error parsing XML file");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$db = new PDO("mysql:host=$dbconf->mysql_host;dbname=$dbconf->mysql_database;charset=utf8",
|
||||||
|
"$dbconf->mysql_username", "$dbconf->mysql_password")
|
||||||
|
or die('Error connecting to mysql server');
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
24
website/queries/friendship.php
Normal file
24
website/queries/friendship.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function selectAllFriends($db, $userID) {
|
||||||
|
return $db->query("
|
||||||
|
SELECT
|
||||||
|
`user`.`username`,
|
||||||
|
`user`.`profilepicture`,
|
||||||
|
`user`.`onlinestatus`,
|
||||||
|
`user`.`role`
|
||||||
|
FROM
|
||||||
|
`user`
|
||||||
|
INNER JOIN
|
||||||
|
`friendship`
|
||||||
|
WHERE
|
||||||
|
`friendship`.`user1ID` = $userID AND
|
||||||
|
`friendship`.`user2ID` = `user`.`userID` OR
|
||||||
|
`friendship`.`user2ID` = $userID AND
|
||||||
|
`friendship`.`user1ID` = `user`.`userID`"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -13,3 +13,8 @@
|
|||||||
@import url("styles/menu.css");
|
@import url("styles/menu.css");
|
||||||
@import url("styles/footer.css");
|
@import url("styles/footer.css");
|
||||||
</style>
|
</style>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include_once("../connect.php");
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user