Added Test-code: Table loading
This commit is contained in:
parent
d83698336c
commit
b5b623afcb
@ -1 +1,4 @@
|
||||
# Projekt Datenerfassung für AST Kanister
|
||||
|
||||
Onsen UI Tutorial: https://onsen.io/v2/guide/pwa/tutorial.html#onsen-ui-pwa-tutorial
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
// define database connection
|
||||
|
||||
|
||||
// define database connection params
|
||||
$host = 'totmann';
|
||||
$user = 'astUser';
|
||||
$pw = "astPasswd";
|
||||
$database = "ast";
|
||||
|
||||
?>
|
||||
44
test/onsen_ui/employee.php
Normal file
44
test/onsen_ui/employee.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
// Controller for employee table
|
||||
|
||||
$op = $_GET['op'];
|
||||
|
||||
switch($op) {
|
||||
|
||||
case 'load':
|
||||
// load all employees from table
|
||||
$con = mysqli_connect($host, $user, $pw, $database);
|
||||
if(!$con) {
|
||||
die('Could not connect: ' . mysqli_error($con));
|
||||
}
|
||||
$sql = "SELECT * FROM employee ORDER BY id";
|
||||
$result = mysqli_query($con, $sql);
|
||||
|
||||
echo "<ons-row>";
|
||||
echo "<ons-col>Id</ons-col><ons-col>First name</ons-col><ons-col>Last name</ons-col><ons-col>Function</ons-col><ons-col>Auth</ons-col><ons-col>E-Mail</ons-col><ons-col>Phone</ons-col><ons-col>Mobile</ons-col>";
|
||||
echo "</ons-row>" . PHP_EOL;
|
||||
|
||||
while($row = mysqli_fetch_array($result)) {
|
||||
echo "<ons-row>";
|
||||
echo "<ons-col>" . $row['id'] . "</ons-col>" . PHP_EOL;
|
||||
echo "<ons-col>" . $row['first_name'] . "</ons-col>" . PHP_EOL;
|
||||
echo "<ons-col>" . $row['last_name'] . "</ons-col>" . PHP_EOL;
|
||||
echo "<ons-col>" . $row['function'] . "</ons-col>" . PHP_EOL;
|
||||
echo "<ons-col>" . $row['authorization'] . "</ons-col>" . PHP_EOL;
|
||||
echo "<ons-col>" . $row['email'] . "</ons-col>" . PHP_EOL;
|
||||
echo "<ons-col>" . $row['phone'] . "</ons-col>" . PHP_EOL;
|
||||
echo "<ons-col>" . $row['mobile'] . "</ons-col>" . PHP_EOL;
|
||||
echo "</ons-row>";
|
||||
}
|
||||
|
||||
mysqli_close($con);
|
||||
|
||||
break;
|
||||
default:
|
||||
echo "no cmd";
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
@ -15,6 +15,18 @@
|
||||
.then(() => console.log('Service worker registered'))
|
||||
.catch(e => console.log(e));
|
||||
}
|
||||
|
||||
function loadData() {
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if(this.readyState == 4 && this.status == 200) {
|
||||
document.getElementById("employeeList").innerHTML = this.responseText;
|
||||
}
|
||||
};
|
||||
xmlhttp.open("GET", "employee.php?op=load", true);
|
||||
xmlhttp.send();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@ -25,6 +37,8 @@
|
||||
</ons-toolbar>
|
||||
Hallo wach
|
||||
<ons-button onclick="alert('clickerick a ding dong')">Click this</ons-button>
|
||||
<ons-button onclick="loadData()">Load data</ons-button>
|
||||
<div id="employeeList"><b>list of employees will be loaded here</b></div>
|
||||
</ons-page>
|
||||
</body>
|
||||
</html>
|
||||
5
test/onsen_ui/test.php
Normal file
5
test/onsen_ui/test.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
phpinfo();
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user