1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- // error reporting
- error_reporting(E_ALL);
- // Include the external configuration file
- require_once '../config.php';
- try {
- // Use the settings from config.php for the PDO connection
- $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- echo 'Connection failed: ' . $e->getMessage();
- exit;
- }
- // Query to fetch activities and their corresponding names
- $query = "
- SELECT a.activityID, an.activityName
- FROM activities a
- JOIN activity_names an ON a.activityID = an.activityID
- ";
- // Execute the query and fetch the results
- $stmt = $pdo->query($query);
- $activities = $stmt->fetchAll(PDO::FETCH_ASSOC);
- // If no activities found
- if (!$activities) {
- echo "No activities found.";
- exit;
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Activity Selection</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- padding: 20px;
- }
- .category-item {
- margin: 5px 0;
- }
- .category-item input {
- margin-right: 10px;
- }
- </style>
- </head>
- <body>
- <h1>Select Activities</h1>
- <form action="submit_activities.php" method="GET">
- <?php foreach ($activities as $activity): ?>
- <div class="activity-item">
- <input type="checkbox" name="activity_ids" value="<?php echo htmlspecialchars($activity['activityID']); ?>">
- <label for="category_<?php echo htmlspecialchars($activity['activityID']); ?>">
- <?php echo htmlspecialchars($activity['activityName']); ?>
- </label>
- </div>
- <?php endforeach; ?>
- <br>
- <button type="submit">Pack it in!</button>
- </form>
- </body>
- </html>
|