<?php
if (isset($_GET) and count($_GET) != 0) {
error_reporting(E_ALL);
$rowFiles = array('Userid', 'Vorname', 'Nachname','Firma','Email','Telefon','Telefon2','Laufzeit','PCLizenzen','Seriennummer','DatumAktiv','DatumEndAktiv');
$row = array_fill_keys($rowFiles, '');
$Host = "localhost";
$User = "david";
$Password = "a";
$dbname = "ABMC-Datenbank";
$tbl="Kunden";
mysql_connect('localhost', 'david', 'a') or die ("Keine Verbindung möglich: ".mysql_error());
mysql_select_db($dbname) or die ("Keine Verbindung möglich: ".mysql_error());
$sql = "SELECT * FROM {$tbl} ";
$data="";
if (!empty($_GET['Userid'])) $data[] = "Userid LIKE '%" .mysql_real_escape_string($_GET["Userid"])."%'";
if (!empty($_GET['Vorname'])) $data[] = "Vorname LIKE '%" .mysql_real_escape_string($_GET["Vorname"])."%'";
if (!empty($_GET['Nachname'])) $data[] = "Nachname LIKE '%" .mysql_real_escape_string($_GET["Nachname"])."%'";
if (!empty($_GET['Firma'])) $data[] = "Firma LIKE '%" .mysql_real_escape_string($_GET["Firma"])."%'";
if (!empty($_GET['Email'])) $data[] = "Email LIKE '%" .mysql_real_escape_string($_GET["Email"])."%'";
if (!empty($_GET['Laufzeit'])) $data[] = "Laufzeit LIKE '%" .mysql_real_escape_string($_GET["Laufzeit"])."%'";
if (!empty($_GET['PCLizenzen'])) $data[] = "PCLizenzen LIKE '%" .mysql_real_escape_string($_GET["PCLizenzen"])."%'";
if (!empty($_GET['Seriennummer'])) $data[] = "Seriennummer LIKE '%" .mysql_real_escape_string($_GET["Seriennummer"])."%'";
if (!empty($_GET['DatumAktiv'])) $data[] = "DatumAktiv LIKE '%" .mysql_real_escape_string($_GET["DatumAktiv"])."%'";
if (!empty($_GET['DatumEndAktiv'])) $data[] = "DatumEndAktiv LIKE '%" .mysql_real_escape_string($_GET["DatumEndAktiv"])."%'";
if(count($data) > 0) $sql .= " WHERE " . implode(" AND ", $data);
$result = mysql_query($sql) or die(mysql_error());
?>
<table border="2">
<tr>
<td>Userid </td>
<td>Vorname</td>
<td>Nachname</td>
<td>Firma</td>
<td>Email</td>
<td>Telefon</td>
<td>Telefon2</td>
<td>Laufzeit</td>
<td>PCLizenzen</td>
<td>Seriennummer</td>
<td>DatumAktiv </td>
<td>DatumEndAktiv</td>
</tr>
<?php
while($row = mysql_fetch_assoc($result)) {
?>
<tr>
<td><?php echo (is_null($row['Userid']) ? " " :$row['Userid']);?></td>
<td><?php echo (is_null($row['Vorname']) ? " " :$row['Vorname']);?></td>
<td><?php echo (is_null($row['Nachname']) ? " " :$row['Nachname']);?></td>
<td><?php echo (is_null($row['Firma']) ? " " :$row['Firma']);?></td>
<td><?php echo (is_null($row['Email']) ? " " :$row['Email']);?></td>
<td><?php echo (is_null($row['Telefon']) ? " " :$row['Telefon']);?></td>
<td><?php echo (is_null($row['Telefon2']) ? " " :$row['Telefon2']);?></td>
<td><?php echo (is_null($row['Laufzeit']) ? " " :$row['Laufzeit']);?></td>
<td><?php echo (is_null($row['PCLizenzen']) ? " " :$row['PCLizenzen']);?></td>
<td><?php echo (is_null($row['Seriennummer']) ? " " :$row['Seriennummer']);?></d>
<td><?php echo (is_null($row['DatumAktiv']) ? " " :$row['DatumAktiv']);?></td>
<td><?php echo (is_null($row['DatumEndAktiv']) ? " " :$row['DatumEndAktiv']);?></td>
</tr>
<?php } ?>
</table>
<?php } ?>