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
// basic connection handling
function ConnectDB($dbname, $user, $pwd) {
// opens a database connection via ODBC
//
// param: $dbname -> dsn (ODBC)
// $user -> login
// $pwd -> password
//
// return: $dbconn -> handle for connection
$dbconn = @odbc_connect($dbname, $user, $pwd)
or die("database connection failed (" . odbc_error() . ")");
return $dbconn;
}
function DisconnectDB($dbconn) {
// disconnects from database (fails if running TAs exists)
// (not really needed since connection is being closed when script terminates)
//
// param: $dbconn -> handle for database
//
// return: none
odbc_close($dbconn);
}
// basic SQL-handling
function ExecuteSQL($dbconn, $sql) {
// executes a sql-statement
//
// param: $dbconn -> handle for connection
// $sql -> sql-statement
//
// return: $sqlresult -> database result
if ($dbconn == 0)
echo "invalid handle!";
$sqlresult = @odbc_exec($dbconn, $sql)
or die("sql-statement execution failed (" . odbc_error() . ")");
return $sqlresult;
}
// basic output-generating
function PrintResultTable($result, $verbose = "off") {
// prints db-results in a html-table
//
// param: $result -> db-result
// $verbose -> "off": table only (default)
// "on": table + row-count ("n record(s) selected")
// return: none
$rowcount = 0;
echo "<table border>\n";
echo "<tr>\n";
// generate table header from column names
for ($i = 1; $i <= odbc_num_fields($result); $i++)
echo "<th>" . odbc_field_name($result,$i) . "</th>\n";
echo "</tr>\n";
// run through all result-rows
while (odbc_fetch_row($result)) {
echo "<tr>\n";
$rowcount++;
// run through all result-columns
for ($i = 1; $i <= odbc_num_fields($result); $i++) {
$field = odbc_result($result, $i);
echo "<td>  $field  </td>\n";
}
}
echo "</table>\n";
// add row-count (verbose mode)
if ($verbose == "on")
echo "<br> << $rowcount record(s) selected >>\n";
}
function CreateDropdownList($result, $name, $size = 1) {
// prints db-results in a html-table
//
// param: $result -> db-result
// $verbose -> "off": table only (default)
// "on": table + row-count ("n record(s) selected")
// return: none
if (odbc_num_fields($result) > 1) {
echo "invalid SQL-statement for dropdown-list";
return 0;
}
echo "<select name=$name size=$size>\n";
// run through all result-rows
while (odbc_fetch_row($result)) {
$field = odbc_result($result, 1);
echo "<option>$field</option>\n";
}
echo "</select>\n";
}
?>