article_overview.php aktualisiert

This commit is contained in:
M_Viper 2024-02-25 17:42:29 +00:00
parent 76d1d4ce71
commit 1028785807
1 changed files with 77 additions and 76 deletions

View File

@ -67,35 +67,36 @@
<th>Aktionen</th>
</tr>
<?php
// Datenbankverbindung herstellen
include_once 'config/config.php';
// Datenbankverbindung herstellen
include_once 'config/config.php';
// Verbindung zur Datenbank herstellen
$conn = new mysqli($host, $username, $password, $database);
if ($conn->connect_error) {
// Verbindung zur Datenbank herstellen
$conn = new mysqli($host, $username, $password, $database);
if ($conn->connect_error) {
die("Verbindung zur Datenbank fehlgeschlagen: " . $conn->connect_error);
}
}
// SQL-Abfrage vorbereiten
$sql = "SELECT * FROM materials";
// SQL-Abfrage vorbereiten
$sql = "SELECT * FROM materials";
// Wenn nach einem Artikel gesucht wird
if(isset($_GET['search']) && !empty($_GET['search'])){
// Wenn nach einem Artikel gesucht wird
if(isset($_GET['search']) && !empty($_GET['search'])){
$search = $_GET['search'];
$sql .= " WHERE
item_name LIKE '%" . $search . "%' OR
manufacturer LIKE '%" . $search . "%' OR
location LIKE '%" . $search . "%' OR
barcode LIKE '%" . $search . "%'";
}
}
$result = $conn->query($sql);
$result = $conn->query($sql);
if ($result->num_rows > 0) {
if ($result->num_rows > 0) {
// Daten ausgeben
while($row = $result->fetch_assoc()) {
$expiration_date = date("d.m.Y", strtotime($row["expiration_date"]));
$ten_days_before_expiry = date("d.m.Y", strtotime("-10 days", strtotime($row["expiration_date"]))); // 10 Tage vor dem Ablaufdatum
$notification_days = intval($row["notification_days"]); // Tage vor dem Ablaufdatum aus der Datenbank lesen
$ten_days_before_expiry = date("d.m.Y", strtotime("-" . $notification_days . " days", strtotime($row["expiration_date"]))); // Tage vor dem Ablaufdatum berechnen
$current_date = date("d.m.Y"); // Aktuelles Datum
echo "<tr";
@ -144,11 +145,11 @@
</form>
</td></tr>";
}
} else {
} else {
echo "<tr><td colspan='9'>Keine Artikel gefunden</td></tr>";
}
$conn->close();
?>
}
$conn->close();
?>
</table>
</div>