Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
<?php
$mysqlhost="localhost"; // MySQL-Host angeben
$mysqluser="111"; // MySQL-User angeben
$mysqlpwd="111"; // Passwort angeben
$mysqldb="111"; // Gewuenschte Datenbank angeben
$connection=mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
mysql_select_db($mysqldb, $connection) or die("Konnte die Datenbank nicht waehlen.");
//Datensatz löschen
if($_GET['action'] == 'delete'){
//SQL-Injections verhindern
$id = mysql_escape_string($_GET['id']);
$sql = "DELETE FROM adressen WHERE id = {$id}";
mysql_query($sql);
}
$sql = <<<SQL
SELECT
id,
anrede,
vorname,
nachname,
strasse,
plz,
wohnort,
kennzeichen,
fsk,
datum
FROM
adressen;
SQL;
$adressen_query = mysql_query($sql) or die("Anfrage nicht erfolgreich");
$anzahl = mysql_num_rows($adressen_query);
echo "Anzahl der Datensätze: {$anzahl}";
?>
<table border="0" cellspacing="10" cellpadding="20">
<tr>
<th scope="col">ID</th>
<th scope="col">Anrede</th>
<th scope="col">Vorname</th>
<th scope="col">Nachname</th>
<th scope="col">Strasse</th>
<th scope="col">PLZ</th>
<th scope="col">Wohnort</th>
<th scope="col">Kennzeichen</th>
<th scope="col">Fuehrerscheinklassen</th>
<th scope="col">Datum</th>
<th scope="col">Funktionen</th>
</tr>
<?php
while ($adr = mysql_fetch_array($adressen_query)){
echo <<<HTML
<tr>
<td>{$adr['id']}</td>
<td>{$adr['anrede']}</td>
<td>{$adr['vorname']}</td>
<td>{$adr['nachname']}</td>
<td>{$adr['strasse']}</td>
<td>{$adr['plz']}</td>
<td>{$adr['wohnort']}</td>
<td>{$adr['kennzeichen']}</td>
<td>{$adr['fsk']}</td>
<td>{$adr['datum']}</td>
<td><a href='?action=delete&id={$adr['id']}'>delete</a></td>
</tr>
HTML;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Navigation Grid</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="jsgrid/jsgrid.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="jsgrid/jsgrid-theme.min.css" />
<script src="jsgrid/jsgrid.min.js" type="text/javascript"></script>
<link type="text/css" href="inc/styles.css" rel="stylesheet">
<style>
.hide
{
display:none;
}
</style>
</head>
<body>
<br>
<a href="map.php" class="buttonweiss">Google Map</a><br><br><br>
<div class="container">
<br />
<div class="table-responsive">
<h3 align="center">Adressen für Zimmersuchende ;-)</h3>
<h4 align="center">Hier bitte die Adresse hinzufügen, aktualisieren oder löschen.</h4><br>
<div id="grid_table"></div>
</div>
</div>
</body>
</html>
<script>
$('#grid_table').jsGrid({
width: "100%",
height: "870px",
filtering: true,
inserting:true,
editing: true,
sorting: true,
paging: true,
autoload: true,
pageSize: 20,
pageButtonCount: 5,
deleteConfirm: "Willst du die Adresse wirklich löschen?",
/* pagerFormat: "Seiten: {first} {prev} {pages} {next} {last} {pageIndex} of {pageCount}",
pagePrevText: "zurück",
pageNextText: "nächste",
pageFirstText: "erste",
pageLastText: "letzte",
pageNavigatorNextText: "...",
pageNavigatorPrevText: "...", */
controller: {
loadData: function(filter){
return $.ajax({
type: "GET",
url: "fetch_data.php",
data: filter
});
},
insertItem: function(item){
return $.ajax({
type: "POST",
url: "fetch_data.php",
data:item
});
},
updateItem: function(item){
return $.ajax({
type: "PUT",
url: "fetch_data.php",
data: item
});
},
deleteItem: function(item){
return $.ajax({
type: "DELETE",
url: "fetch_data.php",
data: item
});
},
},
fields: [
{
name: "id",
type: "hidden",
css: 'hide'
},
{
name: "voller_name",
type: "text",
width: 60,
validate: "required"
},
{
name: "addresse",
type: "text",
width: 80,
validate: "required"
},
{
name: "mobil",
type: "text",
width: 30
},
{
name: "tel",
type: "text",
width: 30
},
{
name: "mail",
type: "text",
width: 60
},
{
name: "www",
type: "text",
width: 60
},
{
name: "lat",
type: "text",
width: 20
},
{
name: "lng",
type: "text",
width: 20
},
/* {
name: "kategorie",
type: "text",
width: 30
}, */
/* {
name: "mobil",
type: "text",
width: 50,
validate: function(value)
{
if(value > 0)
{
return true;
}
}
}, */
{
name: "kategorie",
type: "select",
items: [
{ Name: "", Id: '' },
{ Name: "Hotel", Id: 'Hotel' },
{ Name: "Gasthaus", Id: 'Gasthaus' },
{ Name: "Privat", Id: 'Privat' }
],
valueField: "Id",
textField: "Name"
},
{
type: "control"
}
]
});
</script>
<?php
require_once('inc/config.inc.php');
$connect = new PDO("mysql:host=$dbserver;dbname=$dbname", $dbuser, $dbpass);
$method = $_SERVER['REQUEST_METHOD'];
if($method == 'GET')
{
$data = array(
':voller_name' => "%" . $_GET['voller_name'] . "%",
':addresse' => "%" . $_GET['addresse'] . "%",
':mobil' => "%" . $_GET['mobil'] . "%",
':tel' => "%" . $_GET['tel'] . "%",
':mail' => "%" . $_GET['mail'] . "%",
':www' => "%" . $_GET['www'] . "%",
':lat' => "%" . $_GET['lat'] . "%",
':lng' => "%" . $_GET['lng'] . "%",
':kategorie' => "%" . $_GET['kategorie'] . "%"
);
$query = "SELECT * FROM markers WHERE voller_name LIKE :voller_name AND addresse LIKE :addresse AND mobil LIKE :mobil AND tel LIKE :tel AND mail LIKE :mail AND www LIKE :www AND lat LIKE :lat AND lng LIKE :lng AND kategorie LIKE :kategorie ORDER BY id DESC";
$statement = $connect->prepare($query);
$statement->execute($data);
$result = $statement->fetchAll();
foreach($result as $row)
{
$output[] = array(
'id' => $row['id'],
'voller_name' => $row['voller_name'],
'addresse' => $row['addresse'],
'mobil' => $row['mobil'],
'tel' => $row['tel'],
'mail' => $row['mail'],
'www' => $row['www'],
'lat' => $row['lat'],
'lng' => $row['lng'],
'kategorie' => $row['kategorie']
);
}
header("Content-Type: application/json");
echo json_encode($output);
}
if($method == "POST")
{
$data = array(
':voller_name' => $_POST['voller_name'],
':addresse' => $_POST['addresse'],
':mobil' => $_POST['mobil'],
':tel' => $_POST['tel'],
':mail' => $_POST['mail'],
':www' => $_POST['www'],
':lat' => $_POST['lat'],
':lng' => $_POST['lng'],
':kategorie' => $_POST['kategorie']
);
$query = "INSERT INTO markers (voller_name, addresse, mobil, tel, mail, www, lat, lng, kategorie) VALUES (:voller_name, :addresse, :mobil, :tel, :mail, :www, :lat, :lng, :kategorie)";
$statement = $connect->prepare($query);
$statement->execute($data);
}
if($method == 'PUT')
{
parse_str(file_get_contents("php://input"), $_PUT);
$data = array(
':id' => $_PUT['id'],
':voller_name' => $_PUT['voller_name'],
':addresse' => $_PUT['addresse'],
':mobil' => $_PUT['mobil'],
':tel' => $_PUT['tel'],
':mail' => $_PUT['mail'],
':www' => $_PUT['www'],
':lat' => $_PUT['lat'],
':lng' => $_PUT['lng'],
':type' => $_PUT['type']
);
$query = "
UPDATE markers
SET voller_name = :voller_name,
addresse = :addresse,
mobil = :mobil,
tel = :tel,
mail = :mail,
www = :www,
lat = :lat,
lng = :lng,
type = :type
WHERE id = :id
";
$statement = $connect->prepare($query);
$statement->execute($data);
}
if($method == "DELETE")
{
parse_str(file_get_contents("php://input"), $_DELETE);
$query = "DELETE FROM markers WHERE id = '".$_DELETE["id"]."'";
$statement = $connect->prepare($query);
$statement->execute();
}
?>
Dafür hast Du das aber sehr ordentlich aus der Doku heraus gezogen und umgesetzt!Ich bin leider kein Programmierer oder dergleichen
-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Erstellungszeit: 31. Jan 2020 um 13:47
-- Server-Version: 5.6.41-log
-- PHP-Version: 7.2.7
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Datenbank: `#####_adressen`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `markers`
--
CREATE TABLE `markers` (
`id` int(11) NOT NULL,
`voller_name` varchar(60) CHARACTER SET utf8 NOT NULL,
`addresse` varchar(80) CHARACTER SET utf8 NOT NULL,
`mobil` varchar(30) CHARACTER SET utf8 NOT NULL,
`tel` varchar(30) CHARACTER SET utf8 NOT NULL,
`mail` varchar(60) CHARACTER SET utf8 NOT NULL,
`www` varchar(60) CHARACTER SET utf8 NOT NULL,
`lat` float(10,6) NOT NULL,
`lng` float(10,6) NOT NULL,
`kategorie` enum('Hotel','Gasthaus','Privat') CHARACTER SET utf8 NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Indizes der exportierten Tabellen
--
--
-- Indizes für die Tabelle `markers`
--
ALTER TABLE `markers`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT für exportierte Tabellen
--
--
-- AUTO_INCREMENT für Tabelle `markers`
--
ALTER TABLE `markers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
controller: {
loadData: function (filter) {
var d = $.Deferred();
$.ajax({
type: "GET",
url: "fetch_data.php",
data: filter
}).done(function (response) {
console.log(response);
d.resolve(response);
return;
});
return d.promise();
},
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//header("Content-Type: application/json");
controller: {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//header("Content-Type: application/json");