printer-repair-royalty / view_record.php
Ripcurlsurf's picture
can this be written in php and use an sql for its database
ff9ae2f verified
```php
<?php
$id = $_GET['id'] ?? 0;
try {
$conn = new PDO("mysql:host=localhost;dbname=bhbm_service", "username", "password");
$stmt = $conn->prepare("SELECT * FROM service_records WHERE id = ?");
$stmt->execute([$id]);
$record = $stmt->fetch(PDO::FETCH_ASSOC);
} catch(PDOException $e) {
die("Database error: " . $e->getMessage());
}
?>
<!DOCTYPE html>
<html>
<head>
<title>View Record | BHBM</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 p-8">
<div class="max-w-4xl mx-auto bg-white rounded-lg shadow-md p-6">
<h1 class="text-2xl font-bold mb-6">Service Record Details</h1>
<?php if ($record): ?>
<div class="space-y-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div><strong>Client Name:</strong> <?= htmlspecialchars($record['client_name']) ?></div>
<div><strong>Contact:</strong> <?= htmlspecialchars($record['contact_number']) ?></div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div><strong>Equipment:</strong> <?= htmlspecialchars($record['equipment_type']) ?></div>
<div><strong>Brand:</strong> <?= htmlspecialchars($record['brand']) ?></div>
</div>
<div><strong>Serial Number:</strong> <?= htmlspecialchars($record['serial_number']) ?></div>
<div><strong>Service Date:</strong> <?= date('m/d/Y', strtotime($record['service_date'])) ?></div>
<div><strong>Technician:</strong> <?= htmlspecialchars($record['technician']) ?></div>
<div><strong>Status:</strong> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800"><?= $record['status'] ?></span></div>
<div><strong>Issue Description:</strong><div class="mt-1 p-2 bg-gray-50 rounded"><?= nl2br(htmlspecialchars($record['issue_description'])) ?></div></div>
<div><strong>Service Notes:</strong><div class="mt-1 p-2 bg-gray-50 rounded"><?= nl2br(htmlspecialchars($record['service_notes'])) ?></div></div>
</div>
<div class="mt-6">
<a href="service_records.php" class="px-4 py-2 bg-green-500 text-white rounded">Back to Records</a>
</div>
<?php else: ?>
<p class="text-red-500">Record not found</p>
<?php endif; ?>
</div>
</body>
</html>
```