";
}
}
// Delete Service
if (isset($_GET['delete'])) {
$id = $_GET['delete'];
try {
$stmt = $pdo->prepare("DELETE FROM services WHERE id = ?");
$stmt->execute([$id]);
$msg = "
Service deleted successfully.
";
} catch(Exception $e) {
$msg = "
Error deleting service.
";
}
}
// Fetch Services
try {
$stmt = $pdo->query("SELECT * FROM services ORDER BY id DESC");
$services = $stmt->fetchAll();
} catch (PDOException $e) {
if ($e->getCode() == '42S02') {
$pdo->exec("CREATE TABLE IF NOT EXISTS `services` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(150) NOT NULL,
`description` text NOT NULL,
`image` varchar(255) NOT NULL,
`is_active` tinyint(1) NOT NULL DEFAULT 1,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
// Insert default services data
$pdo->exec("INSERT INTO `services` (`title`, `description`, `image`, `is_active`) VALUES
('Aluminium Pantry Cupboard', 'Premium quality, rust-proof aluminium pantry cupboards customized to fit your kitchen space perfectly with modern luxury finishes.', 'pantry.jpg', 1),
('TV Wall Design', 'Modern TV wall units incorporating LED lighting, floating shelves, and high-end materials to elevate your living room.', 'tv-wall.jpg', 1),
('Wall Decoration', 'Aesthetic and durable wall decorations using advanced cladding and interior materials.', 'wall-deco.jpg', 1),
('Clothing Wardrobe', 'Spacious, elegantly designed aluminium and glass wardrobes tailored for maximum storage and style.', 'wardrobe.jpg', 1),
('Partition Decoration Wall', 'Stylish glass and aluminium partition walls to divide spaces while maintaining an open, modern feel.', 'partition.jpg', 1),
('Granite Works', 'High-quality granite countertops and fittings for kitchens, bathrooms, and commercial spaces.', 'granite.jpg', 1),
('Island Table', 'Custom-built kitchen island tables providing extra workspace and a contemporary focal point for your kitchen.', 'island-table.jpg', 1),
('Bar Counter', 'Luxurious bar counters for home or commercial use, designed with premium finishes and ambient lighting.', 'bar-counter.jpg', 1),
('Dressing Table', 'Modern dressing tables featuring elegant mirrors, built-in lighting, and sleek storage solutions.', 'dressing-table.jpg', 1)");
$stmt = $pdo->query("SELECT * FROM services ORDER BY id DESC");
$services = $stmt->fetchAll();
} else {
$msg = "