prepare("INSERT INTO price_history (fuel_type_id, price, date) VALUES (?, ?, ?)"); $stmt->execute([$fuel_type_id, $price, $date]); $message = '
Price added successfully!
'; } catch (PDOException $e) { $message = '
Error: ' . $e->getMessage() . '
'; } } else { $message = '
Please fill in all fields.
'; } } // Fetch related data for forms $fuel_types = $pdo->query("SELECT id, name FROM fuel_types ORDER BY name")->fetchAll(PDO::FETCH_ASSOC); // Fetch all price history with fuel type name $stmt = $pdo->query(" SELECT ph.id, ph.price, ph.date, ft.name AS fuel_type_name FROM price_history ph JOIN fuel_types ft ON ph.fuel_type_id = ft.id ORDER BY ph.date DESC, ft.name "); $price_history = $stmt->fetchAll(PDO::FETCH_ASSOC); ?>

Price History

History of fuel prices.

Date Fuel Type Price
No price history found. Add one to get started.
Add New Price