Skip to content
Snippets Groups Projects
Commit 33cbd734 authored by Julian Dehne's avatar Julian Dehne
Browse files

fixed problem in Darstellung (wenn man mit mehreren Clienten arbeitet :-))

parent 959dfa7f
No related branches found
No related tags found
No related merge requests found
drop TABLE `users`;
CREATE TABLE `users` (
`name` varchar(400) NOT NULL,
`password` varchar(200) NOT NULL,
`email` varchar(400) NOT NULL,
`token` varchar(800) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('teststudent1', 'egal', 'test1@uni.de', 'test1');
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('teststudent1', 'egal', 'test1@uni.de', 'test1');
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('teststudent2', 'egal', 'test2@uni.de', 'test2');
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('teststudent3', 'egal', 'test3@uni.de', 'test3');
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('teststudent4', 'egal', 'test4@uni.de', 'test4');
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('teststudent5', 'egal', 'test5@uni.de', 'test5');
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('teststudent6', 'egal', 'test6@uni.de', 'test6');
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('teststudent7', 'egal', 'test7@uni.de', 'test7');
......@@ -31,12 +31,8 @@ CREATE TABLE `users` (
`token` varchar(800) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `users` (`name`, `password`, `email`, `token`) VALUES
('Axel Wiepke', 'password', 'wiepke@uni.de', '5ab0f28f75d23');
ALTER TABLE `users`
ADD UNIQUE KEY `password` (`password`);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
......
......@@ -47,6 +47,9 @@ function getProjects(user) {
function printGroupTable(student1, student2, student3, student4) {
var innerurl = "../database/getAdresses.php?student1=" + student1 + "&student2=" + student2 + "&student3=" + student3 + "&student4=" + student4;
/*if (student4) {
innerurl = innerurl + "&student4=" + student4;
}*/
$.ajax({ //get email adresses in this ajax.
student1: "" + student1,
student2: "" + student2,
......
......@@ -10,29 +10,59 @@ include_once 'config.php';
$student1 = $_GET['student1'];
$student2 = $_GET['student2'];
if (isset($_GET['student3'])) {
$student3 = $_GET['student3'];
} else{$student3 = "";}
if (isset($_GET['student4'])) {
$student4 = $_GET['student4'];
}else {$student4 = "";}
if (isset($_GET['student5'])) {
$student5 = $_GET['student5'];
}else {$student5 = "";}
$adresses = array();
$student3 = $_GET['student3'];
$addresses = array();
if (!$db) {
die('Could not connect: ' . mysqli_error($db));
}
mysqli_select_db($db, "fltrail");
$sql = "SELECT name,email FROM `users` WHERE `name`='".$student1."' OR `name` = '".$student2."' OR `name` = '".$student3."' OR `name` = '".$student4."';";
$sql = "SELECT name,email FROM `users` WHERE `name`='".$student1."' OR `name` = '".$student2."' OR `name` = '".$student3."'";
if (isset($_GET['student4'])) {
$sql = $sql . "OR `name` = '".$_GET['student4']."';";
} else {
$sql = $sql . ";";
}
if ($result = mysqli_query($db, $sql)) {
while ($row = mysqli_fetch_array($result)) {
$adresses[] = $row;
$addresses[] = $row;
}
}
function filter ($arrayelem) {
return array($arrayelem[0], $arrayelem[1]);
};
$addresses = array_map('filter', $addresses);
$students = array($student1, $student2, $student3);
if (isset($_GET['student4']) && $_GET['student4'] != "undefined" ) {
$students = array($student1, $student2, $student3, $_GET['student4']);
}
function attributeEmail($studentName, $addresses) {
foreach ($addresses as $value) {
if ($value[0] == $studentName) {
return $value[1];
}
}
}
$finalArray = array();
foreach ($students as $student) {
$email = attributeEmail($student, $addresses);
if (!$email) {
$email = "";
}
array_push($finalArray, array("name" => $student, "email" => $email));
}
echo json_encode($adresses);
echo json_encode($finalArray);
mysqli_close($db);
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment