rep init
This commit is contained in:
commit
9767c6bddc
22 changed files with 551 additions and 0 deletions
68
app/public/function/function.php
Normal file
68
app/public/function/function.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/*
|
||||
Ajmi Yasmin, 13.02.2024
|
||||
Funktionen/Prozeduren
|
||||
*/
|
||||
|
||||
function getSite($site){
|
||||
if(isset($_GET['site'])){
|
||||
include_once('sites/'.$_GET['site'].'.php');
|
||||
}else{
|
||||
include_once('sites/'.$site.'.php');
|
||||
}
|
||||
}
|
||||
|
||||
function makeStatment($query, $params = null) {
|
||||
try {
|
||||
global $con;
|
||||
$stmt = $con->prepare($query);
|
||||
$stmt->execute($params);
|
||||
return $stmt;
|
||||
} catch (Exception $e) {
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
|
||||
function makeTable($query, $params = null)
|
||||
{
|
||||
$stmt = makeStatment($query, $params);
|
||||
if($stmt instanceof Exception) {
|
||||
echo ''. $stmt->getMessage() .'';
|
||||
} else {
|
||||
// Tabelle erstellen
|
||||
$meta = array();
|
||||
//Spaltenüberschribt dynamisch
|
||||
echo '<table class="table">
|
||||
<tr>';
|
||||
|
||||
|
||||
for ($i=0; $i < $stmt->columnCount(); $i++) {
|
||||
$meta[] = $stmt->getColumnMeta($i);
|
||||
echo '<th>'.$meta[$i]['name'].'</th>';
|
||||
}
|
||||
|
||||
echo '</tr>';
|
||||
|
||||
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
echo'<tr>';
|
||||
foreach ($row as $r) {
|
||||
echo '<td>'.$r.'</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
function insertInto($tablename, $columnlist, $valuelist) {
|
||||
global $con;
|
||||
$query = 'INSERT INTO '.$tablename.' ('.implode(',',$columnlist).') VALUES(?)';
|
||||
$params = array(implode(',', $valuelist));
|
||||
$stmt = makeStatment($query, $params);
|
||||
if($stmt instanceof Exception) {
|
||||
return $stmt;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue