-
Notifications
You must be signed in to change notification settings - Fork 0
/
Abfrage_Startnummern.php
56 lines (48 loc) · 1.62 KB
/
Abfrage_Startnummern.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
//Quelle: http://stefan-draeger-software.de/blog/android-app-mit-mysql-datenbank-verbinden/
//Datenbankverbindung aufbauen
$connection = mysqli_connect("localhost","root","","android_connect");
if (mysqli_connect_errno()) {
echo mysql_errno($connection) . ": " . mysql_error($connection). "\n";
die();
}
getMessstationencount($connection);
//getAllPlants($connection);
//Liefert alle deutschen Pflanzennamen zurück.
function getAllPlants($connection){
$sqlStmt = "INSERT INTO `android_connect`.`messstation_".$_GET["name"]."` (`Startnummer`, `Zeitpunkt`) VALUES ('".$_GET["nummer"]."', CURRENT_TIMESTAMP);";
$result = mysqli_query($connection,$sqlStmt);
$data = array();
if ($result = $connection->query($sqlStmt)) {
while ($row = $result->fetch_assoc()) {
$id = $row["id"];
$de_name = $row["de_name"];
array_push($data,array("ID"=> $id,"de_name"=>$de_name));
}
// Das Objekt wieder freigeben.
}
$result->free();
closeConnection($connection);
//Das Array durchlaufen und nur die deutschen Namen ausgeben.
foreach ($data as $d){
echo $d["de_name"];
echo "|";
}
}
function getMessstationencount ($connection) {
$sqlStmt = "SELECT Startnummer FROM `namen` WHERE 1 ORDER BY `namen`.`Startnummer` ASC";
$result = mysqli_query($connection,$sqlStmt);
if ($result = $connection->query($sqlStmt)) {
while ($row = $result->fetch_assoc()) {
$id = $row["Startnummer"];
echo $id."|";
}
$result->free();
closeConnection($connection);
}
}
//Verbindung schließen.
function closeConnection($connection){
mysqli_close($connection);
}
?>