Dateien hochladen nach „“
...
This commit is contained in:
parent
2e41195d49
commit
143c969250
17
apprentice_add.php
Normal file
17
apprentice_add.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
require './db_config.php';
|
||||
$post = file_get_contents('php://input');
|
||||
$post = json_decode($post);
|
||||
|
||||
$sql = "INSERT INTO apprentice (firstname, lastname, groupid, sex, date_of_birth, date_joined, date_leave) VALUES ('" . $post->firstname . "','" . $post->lastname . "',";
|
||||
$sql .= $post->groupid . ", '" . $post->sex . "','" . $post->date_of_birth . "', '" . $post->date_joined . "',''";
|
||||
$result = $mysqli->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM apprentice Order by apprenticeid desc LIMIT 1";
|
||||
$result = $mysqli->query($sql);
|
||||
$data = $result->fetch_assoc();
|
||||
|
||||
echo json_encode($data);
|
||||
?>
|
||||
|
24
apprentice_list.php
Normal file
24
apprentice_list.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require './db_config.php';
|
||||
|
||||
$sql = "SELECT apprenticeid, firstname, lastname, a.groupid, groupname, sex, date_of_birth, date_joined, date_leave ";
|
||||
$sql .= "FROM apprentice a left join gruppe g on a.groupid = g.groupid ";
|
||||
|
||||
|
||||
$result = $mysqli->query($sql);
|
||||
if ($result != null)
|
||||
{
|
||||
while($row = $result->fetch_assoc()){
|
||||
$json[] = $row;
|
||||
}
|
||||
|
||||
$data['apprentice'] = $json;
|
||||
$result = mysqli_query($mysqli,$sql);
|
||||
echo json_encode($data);
|
||||
}
|
||||
else
|
||||
echo json_encode("keine Daten empfangen!");
|
||||
|
||||
?>
|
||||
|
16
db_config.php
Normal file
16
db_config.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE");
|
||||
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
|
||||
|
||||
const DB_USER = "root";
|
||||
const DB_PASSWORD = "";
|
||||
const DB_DATABASE = "bildungsdb";
|
||||
const DB_HOST = "localhost";
|
||||
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
|
||||
|
||||
if(mysqli_connect_errno()){
|
||||
echo mysqli_connect_error();
|
||||
}
|
||||
|
||||
|
16
group_add.php
Normal file
16
group_add.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
require './db_config.php';
|
||||
$post = file_get_contents('php://input');
|
||||
$post = json_decode($post);
|
||||
|
||||
$sql = "INSERT INTO group (groupname,date_started) VALUES ('" . $post->groupname . "','" . $post->date . "')";
|
||||
$result = $mysqli->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM group Order by groupid desc LIMIT 1";
|
||||
$result = $mysqli->query($sql);
|
||||
$data = $result->fetch_assoc();
|
||||
|
||||
echo json_encode($data);
|
||||
?>
|
||||
|
27
group_data.php
Normal file
27
group_data.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require 'db_config.php';
|
||||
|
||||
if(isset($_GET["id"]))
|
||||
{
|
||||
$id = $_GET["id"];
|
||||
$sql = "SELECT `groupid`, `groupname`, `date_started`, `Anmerkung` FROM `gruppe` WHERE groupid = " . $id . ";";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT `groupid`, `groupname`, `date_started`, `Anmerkung` FROM `gruppe`;";
|
||||
}
|
||||
|
||||
$result = $mysqli->query($sql);
|
||||
if ($result != null)
|
||||
{
|
||||
while($row = $result->fetch_assoc()){
|
||||
$json[] = $row;
|
||||
}
|
||||
|
||||
$data['data'] = $json;
|
||||
$result = mysqli_query($mysqli,$sql);
|
||||
echo json_encode($data);
|
||||
}
|
||||
else
|
||||
echo "<br><br>keine Daten empfangen!<br><br>";
|
||||
?>
|
Loading…
Reference in New Issue
Block a user