umgestellt auf Docker
This commit is contained in:
BIN
uploads/R001/R001_0.jpg
Normal file
BIN
uploads/R001/R001_0.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 493 KiB |
BIN
uploads/R001/R001_1.jpg
Normal file
BIN
uploads/R001/R001_1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 524 KiB |
BIN
uploads/R001/R001_2.jpg
Normal file
BIN
uploads/R001/R001_2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 496 KiB |
44
uploads/R001/load_bilder.php
Normal file
44
uploads/R001/load_bilder.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
require_once 'db_connection.php';
|
||||
|
||||
// 1. Alle bestehenden Einträge in rezepte_bilder löschen
|
||||
$link->query("DELETE FROM rezepte_bilder");
|
||||
$link->query("ALTER TABLE rezepte_bilder AUTO_INCREMENT = 1");
|
||||
echo "Alle Einträge in rezepte_bilder wurden gelöscht.<br>";
|
||||
|
||||
// 2. Bilder für R001 bis R043 eintragen
|
||||
for ($i = 1; $i <= 43; $i++) {
|
||||
$r_nummer = 'R' . str_pad($i, 3, '0', STR_PAD_LEFT);
|
||||
$upload_dir = 'uploads/' . $r_nummer . '/';
|
||||
|
||||
if (file_exists($upload_dir)) {
|
||||
$files = glob($upload_dir . $r_nummer . '_*.jpg');
|
||||
if (!empty($files)) {
|
||||
// Hole die korrekte rezepte_id (id aus Rezepte für Rezeptnummer = $i)
|
||||
$sql_rezept = "SELECT id FROM Rezepte WHERE Rezeptnummer = ?";
|
||||
$stmt_rezept = $link->prepare($sql_rezept);
|
||||
$stmt_rezept->bind_param('i', $i);
|
||||
$stmt_rezept->execute();
|
||||
$result_rezept = $stmt_rezept->get_result();
|
||||
|
||||
if ($result_rezept->num_rows > 0) {
|
||||
$row_rezept = $result_rezept->fetch_assoc();
|
||||
$rezepte_id = $row_rezept['id']; // Korrekte id aus Rezepte (z. B. 6 für Rezeptnummer 1)
|
||||
|
||||
foreach ($files as $file) {
|
||||
$file_name = basename($file);
|
||||
$datei_pfad = 'uploads/' . $r_nummer . '/' . $file_name;
|
||||
|
||||
$insert_sql = "INSERT INTO rezepte_bilder (rezepte_id, datei_pfad) VALUES (?, ?)";
|
||||
$insert_stmt = $link->prepare($insert_sql);
|
||||
$insert_stmt->bind_param('is', $rezepte_id, $datei_pfad);
|
||||
$insert_stmt->execute();
|
||||
echo "Eintrag: rezepte_id = $rezepte_id, datei_pfad = $datei_pfad<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "Fertig!";
|
||||
?>
|
||||
Reference in New Issue
Block a user