109 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			109 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| require_once "../src/adverts.php";
 | |
| require_once "../src/categories.php";
 | |
| 
 | |
| // Überprüft ob Kategorie ID vorhanden ist
 | |
| if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
 | |
|     echo "Fehler: Kategorie-ID ist erforderlich";
 | |
|     exit;
 | |
| }
 | |
| 
 | |
| $categoryId = (int)$_GET['id'];
 | |
| 
 | |
| // Get category details
 | |
| $allCategories = Categories::getAllCategories();
 | |
| $categoryName = "";
 | |
| 
 | |
| foreach ($allCategories as $category) {
 | |
|     if ($category['id'] == $categoryId) {
 | |
|         $categoryName = $category['name'];
 | |
|         break;
 | |
|     }
 | |
| }
 | |
| 
 | |
| if (empty($categoryName)) {
 | |
|     echo "Fehler: Kategorie nicht gefunden";
 | |
|     exit;
 | |
| }
 | |
| 
 | |
| // Anzeigen für diese Kategorie erhalten
 | |
| $adverts = Adverts::getAdvertsByCategoryId($categoryId);
 | |
| ?>
 | |
| 
 | |
| <!DOCTYPE html>
 | |
| <html lang="de">
 | |
| <head>
 | |
|     <meta charset="UTF-8">
 | |
|     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | |
|     <title>Inserate in <?php echo htmlspecialchars($categoryName); ?></title>
 | |
|     <style>
 | |
|         body {
 | |
|             font-family: Arial, sans-serif;
 | |
|             max-width: 800px;
 | |
|             margin: 0 auto;
 | |
|             padding: 20px;
 | |
|         }
 | |
|         h1 {
 | |
|             color: #333;
 | |
|         }
 | |
|         .inserat {
 | |
|             border: 1px solid #ddd;
 | |
|             padding: 15px;
 | |
|             margin-bottom: 15px;
 | |
|             border-radius: 5px;
 | |
|         }
 | |
|         .inserat h2 {
 | |
|             margin-top: 0;
 | |
|         }
 | |
|         .inserat-date {
 | |
|             color: #666;
 | |
|             font-size: 0.8em;
 | |
|         }
 | |
|         .no-inserate {
 | |
|             color: #666;
 | |
|             font-style: italic;
 | |
|         }
 | |
|         .back-link {
 | |
|             margin-top: 20px;
 | |
|         }
 | |
|     </style>
 | |
| </head>
 | |
| <body>
 | |
|     <h1>Inserate in Kategorie: <?php echo htmlspecialchars($categoryName); ?></h1>
 | |
| 
 | |
|     <div style="margin-bottom: 20px;">
 | |
|         <a href="create_advert.php" style="display: inline-block; padding: 10px 15px; background-color: #4CAF50; color: white; text-decoration: none; border-radius: 5px;">Neues Inserat erstellen</a>
 | |
|     </div>
 | |
| 
 | |
|     <?php if (empty($adverts)): ?>
 | |
|         <p class="no-inserate">Keine Inserate in dieser Kategorie gefunden.</p>
 | |
|     <?php else: ?>
 | |
|         <?php foreach ($adverts as $advert): ?>
 | |
|             <div class="inserat">
 | |
|                 <h2><?php echo htmlspecialchars($advert['name']); ?></h2>
 | |
|                 <p><?php echo htmlspecialchars($advert['description']); ?></p>
 | |
|                 <p class="inserat-date">Erstellt am: <?php echo htmlspecialchars($advert['date']); ?></p>
 | |
|                 <?php if (isset($advert['user_name']) || isset($advert['user_email']) || isset($advert['user_telephone'])): ?>
 | |
|                     <div class="user-contact">
 | |
|                         <h3>Kontaktinformationen:</h3>
 | |
|                         <?php if (isset($advert['user_name'])): ?>
 | |
|                             <p><strong>Name:</strong> <?php echo htmlspecialchars($advert['user_name']); ?></p>
 | |
|                         <?php endif; ?>
 | |
|                         <?php if (isset($advert['user_email'])): ?>
 | |
|                             <p><strong>E-Mail:</strong> <?php echo htmlspecialchars($advert['user_email']); ?></p>
 | |
|                         <?php endif; ?>
 | |
|                         <?php if (isset($advert['user_telephone'])): ?>
 | |
|                             <p><strong>Telefon:</strong> <?php echo htmlspecialchars($advert['user_telephone']); ?></p>
 | |
|                         <?php endif; ?>
 | |
|                     </div>
 | |
|                 <?php endif; ?>
 | |
|             </div>
 | |
|         <?php endforeach; ?>
 | |
|     <?php endif; ?>
 | |
| 
 | |
|     <div class="back-link">
 | |
|         <a href="index.php">Zurück zu den Kategorien</a>
 | |
|     </div>
 | |
| </body>
 | |
| </html>
 |