-- Host: 127.0.0.1:3306
-- Generation Time: Oct 16, 2024 at 06:33 PM
-- Server version: 10.11.9-MariaDB
-- PHP Version: 7.2.34
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /;
/!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/!40101 SET NAMES utf8mb4 */;
--
-- Database: u406552082_info
--
-- Table structure for table admins
CREATE TABLE admins (
id int(11) NOT NULL,
username varchar(50) NOT NULL,
password varchar(255) NOT NULL,
email varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table appointments
CREATE TABLE appointments (
id int(11) NOT NULL,
package_id int(11) NOT NULL,
appointment_date datetime NOT NULL,
proposed_appointment_date datetime DEFAULT NULL,
name varchar(255) NOT NULL,
email varchar(255) NOT NULL,
phone varchar(20) NOT NULL,
age int(3) DEFAULT NULL,
gender enum('Male','Female','Other') DEFAULT NULL,
address varchar(255) DEFAULT NULL,
preferred_contact_method enum('Email','Phone','WhatsApp') DEFAULT NULL,
additional_notes text DEFAULT NULL,
admin_notes text DEFAULT NULL,
status enum('Pending','Confirmed','Completed','Cancelled') DEFAULT 'Pending',
created_at timestamp NULL DEFAULT current_timestamp(),
patient_id int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table budgets
CREATE TABLE budgets (
id int(11) NOT NULL,
month varchar(7) DEFAULT NULL,
budgeted_revenue decimal(10,2) DEFAULT NULL,
budgeted_expenses decimal(10,2) DEFAULT NULL,
notes text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table
Assistant
User
ok, add more codes and make it cool design
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
CREATE TABLE comments (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
sender enum('patient','doctor','admin') NOT NULL,
message text NOT NULL,
timestamp datetime DEFAULT current_timestamp(),
parent_id int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table doctors
CREATE TABLE doctors (
id int(11) NOT NULL,
employee_id int(11) NOT NULL,
name varchar(255) NOT NULL,
username varchar(100) NOT NULL,
password varchar(255) NOT NULL,
email varchar(255) NOT NULL,
specialization varchar(255) DEFAULT NULL,
phone varchar(20) DEFAULT NULL,
registration_date date DEFAULT curdate(),
profile_picture varchar(255) DEFAULT NULL,
department varchar(100) DEFAULT NULL,
date_of_joining date DEFAULT NULL,
status enum('active','inactive') DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table doctor_patient
CREATE TABLE doctor_patient (
id int(11) NOT NULL,
doctor_id int(11) NOT NULL,
patient_id int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table employees
CREATE TABLE employees (
id int(11) NOT NULL,
name varchar(255) NOT NULL,
role enum('admin','doctor','staff','accountant') NOT NULL,
email varchar(255) NOT NULL,
phone varchar(20) DEFAULT NULL,
department varchar(100) DEFAULT NULL,
date_of_joining date DEFAULT NULL,
status enum('active','inactive') DEFAULT 'active',
username varchar(100) NOT NULL,
password varchar(255) NOT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
profile_picture varchar(255) DEFAULT NULL,
specialization varchar(255) DEFAULT NULL,
is_online tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table expenses
CREATE TABLE expenses (
id int(11) NOT NULL,
expense_date date NOT NULL,
category varchar(100) NOT NULL,
description varchar(255) DEFAULT NULL,
amount decimal(10,2) NOT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table health_records
CREATE TABLE health_records (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
blood_pressure varchar(20) DEFAULT NULL,
weight decimal(5,2) DEFAULT NULL,
bmi decimal(4,2) DEFAULT NULL,
cholesterol decimal(5,2) DEFAULT NULL,
prescription text DEFAULT NULL,
treatment_progress text DEFAULT NULL,
record_date date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table insurance_claims
CREATE TABLE insurance_claims (
id int(11) NOT NULL,
patient_id int(11) DEFAULT NULL,
invoice_id int(11) DEFAULT NULL,
claim_amount decimal(10,2) DEFAULT NULL,
status enum('Pending','Approved','Rejected') DEFAULT NULL,
submission_date date DEFAULT NULL,
processing_date date DEFAULT NULL,
notes text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table invoices
CREATE TABLE invoices (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
service_name varchar(255) NOT NULL,
service_description text DEFAULT NULL,
cost decimal(10,2) NOT NULL,
tax_rate decimal(5,2) DEFAULT 0.00,
discount decimal(5,2) DEFAULT 0.00,
total_amount decimal(10,2) NOT NULL,
invoice_date date DEFAULT curdate(),
due_date date DEFAULT NULL,
notes text DEFAULT NULL,
tax decimal(5,2) DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table invoice_services
CREATE TABLE invoice_services (
id int(11) NOT NULL,
invoice_id int(11) NOT NULL,
service_id int(11) NOT NULL,
service_name varchar(255) NOT NULL,
cost decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table packages
CREATE TABLE packages (
id int(11) NOT NULL,
package_name varchar(255) NOT NULL,
description text DEFAULT NULL,
details text DEFAULT NULL,
created_at timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patients
CREATE TABLE patients (
id int(11) NOT NULL,
name varchar(100) NOT NULL,
age int(3) DEFAULT NULL,
gender enum('Male','Female','Other') DEFAULT NULL,
phone varchar(20) DEFAULT NULL,
email varchar(100) DEFAULT NULL,
medical_history text DEFAULT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
date_of_birth date DEFAULT NULL,
registration_datetime datetime DEFAULT current_timestamp(),
registration_date date DEFAULT NULL,
status enum('Initial Consultation','Diagnostic Phase','Treatment in Progress','Improving','Monitoring','Maintenance Phase','Awaiting Test Results','Follow-up Needed','Paused','Completed Program','Relapsed','Discontinued','Inactive') DEFAULT 'Initial Consultation',
doctor_id int(11) DEFAULT NULL,
address varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_basic_info
CREATE TABLE patient_basic_info (
patient_id int(11) NOT NULL,
gender enum('Male','Female','Other') NOT NULL,
age int(3) NOT NULL,
weight decimal(5,2) NOT NULL,
height decimal(5,2) NOT NULL,
name varchar(100) NOT NULL,
email varchar(100) NOT NULL,
phone varchar(20) NOT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_consent
CREATE TABLE patient_consent (
patient_id int(11) NOT NULL,
consent enum('accepted','declined') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_consultation
CREATE TABLE patient_consultation (
patient_id int(11) NOT NULL,
scheduled_at datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_goals
CREATE TABLE patient_goals (
patient_id int(11) NOT NULL,
primary_health_goals text NOT NULL,
health_concerns text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_health_metrics
CREATE TABLE patient_health_metrics (
patient_id int(11) NOT NULL,
exercise_frequency enum('Daily','Weekly','Rarely','Never') NOT NULL,
diet enum('Yes','No') NOT NULL,
diet_specify varchar(255) DEFAULT NULL,
sleep_average enum('<5 Hours','5-7 Hours','7-9 Hours','>9 Hours') NOT NULL,
smoking_status enum('Yes','No','Occasionally') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_logins
CREATE TABLE patient_logins (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
username varchar(50) NOT NULL,
password varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_medical_history
CREATE TABLE patient_medical_history (
patient_id int(11) NOT NULL,
chronic_conditions enum('Yes','No') NOT NULL,
chronic_conditions_specify varchar(255) DEFAULT NULL,
medications enum('Yes','No') NOT NULL,
medications_list text DEFAULT NULL,
major_surgeries enum('Yes','No') NOT NULL,
major_surgeries_specify varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table payments
CREATE TABLE payments (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
invoice_id int(11) NOT NULL,
amount_paid decimal(10,2) NOT NULL,
payment_date date NOT NULL,
payment_method varchar(50) DEFAULT NULL,
notes text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table prescriptions
CREATE TABLE prescriptions (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
doctor_id int(11) DEFAULT NULL,
medications text NOT NULL,
instructions text DEFAULT NULL,
date_prescribed datetime DEFAULT current_timestamp(),
status enum('active','inactive') DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table questionnaire_responses
CREATE TABLE questionnaire_responses (
id int(11) NOT NULL,
session_id varchar(255) NOT NULL,
page_number int(2) NOT NULL,
question varchar(255) NOT NULL,
answer text NOT NULL,
submitted_at timestamp NULL DEFAULT current_timestamp(),
consent enum('Yes','No') DEFAULT 'No'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table salaries
CREATE TABLE salaries (
id int(11) NOT NULL,
employee_id int(11) NOT NULL,
basic_salary decimal(10,2) NOT NULL,
bonuses decimal(10,2) DEFAULT 0.00,
deductions decimal(10,2) DEFAULT 0.00,
overtime_hours int(11) DEFAULT 0,
overtime_rate decimal(10,2) DEFAULT 0.00,
tax decimal(10,2) DEFAULT 0.00,
payment_date date NOT NULL,
net_salary decimal(10,2) NOT NULL,
status enum('Pending','Paid') DEFAULT 'Pending',
notes text DEFAULT NULL,
payslip_path varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table services
CREATE TABLE services (
service_id int(11) NOT NULL,
service_name varchar(255) NOT NULL,
service_price decimal(10,2) NOT NULL,
service_description text DEFAULT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE invoice_services
ADD CONSTRAINT invoice_services_ibfk_1 FOREIGN KEY (invoice_id) REFERENCES invoices (id) ON DELETE CASCADE,
ADD CONSTRAINT invoice_services_ibfk_2 FOREIGN KEY (service_id) REFERENCES services (service_id) ON DELETE CASCADE;
--
-- Constraints for table patients
ALTER TABLE patients
ADD CONSTRAINT patients_ibfk_1 FOREIGN KEY (doctor_id) REFERENCES doctors (id) ON DELETE SET NULL ON UPDATE CASCADE;
--
-- Constraints for table patient_logins
ALTER TABLE patient_logins
ADD CONSTRAINT patient_logins_ibfk_1 FOREIGN KEY (patient_id) REFERENCES patients (id) ON DELETE CASCADE;
--
-- Constraints for table payments
ALTER TABLE payments
ADD CONSTRAINT payments_ibfk_1 FOREIGN KEY (patient_id) REFERENCES patients (id) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT payments_ibfk_2 FOREIGN KEY (invoice_id) REFERENCES invoices (id) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table prescriptions
ALTER TABLE prescriptions
ADD CONSTRAINT prescriptions_ibfk_1 FOREIGN KEY (patient_id) REFERENCES patients (id) ON DELETE CASCADE,
ADD CONSTRAINT prescriptions_ibfk_2 FOREIGN KEY (doctor_id) REFERENCES doctors (id) ON DELETE SET NULL;
--
-- Constraints for table salaries
ALTER TABLE salaries
ADD CONSTRAINT salaries_ibfk_1 FOREIGN KEY (employee_id) REFERENCES employees (id) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /;
/!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /;
/!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;), i want to create folder called (longeva_health_journey_answers) this folder has file shows info who made survey from this page 8 (<?php
// longeva_health_journey/pages/page8.php
// Enable error reporting for debugging (Remove in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Start session and include database connection
session_start();
require '../db_connect.php';
// Check if patient_id is set; if not, redirect to page3.php to collect information
if (!isset($_SESSION['patient_id'])) {
header("Location: page3.php");
exit();
}
// Fetch existing patient_basic_info and consultation date/time to pre-fill the form
try {
// Fetch patient basic info
stmt=pdo->prepare("SELECT * FROM patient_basic_info WHERE patient_id = ?");
stmt−>execute([_SESSION['patient_id']]);
basicinfo=stmt->fetch();
if ($basic_info) {
$name = htmlspecialchars($basic_info['name']);
$email = htmlspecialchars($basic_info['email']);
$phone = htmlspecialchars($basic_info['phone']);
$gender = htmlspecialchars($basic_info['gender']);
$age = htmlspecialchars($basic_info['age']);
$weight = htmlspecialchars($basic_info['weight']);
$height = htmlspecialchars($basic_info['height']);
}
// Fetch existing consultation date and time if available
$stmt = $pdo->prepare("SELECT scheduled_at FROM patient_consultation WHERE patient_id = ?");
$stmt->execute([$_SESSION['patient_id']]);
$consultation = $stmt->fetch();
if ($consultation) {
// Ensure the datetime format is compatible with input[type="datetime-local"]
$scheduled_at = date('Y-m-d\TH:i', strtotime($consultation['scheduled_at']));
}
// Build the SQL query with filters
$sql = "
SELECT p.*, pl.username,
hr.blood_pressure, hr.weight, hr.bmi, hr.cholesterol,
hr.prescription, hr.treatment_progress, hr.record_date
FROM patients p
LEFT JOIN patient_logins pl ON p.id = pl.patient_id
LEFT JOIN (
SELECT patient_id, blood_pressure, weight, bmi, cholesterol,
prescription, treatment_progress, record_date,
ROW_NUMBER() OVER (PARTITION BY patient_id ORDER BY record_date DESC) as rn
FROM health_records
) hr ON p.id = hr.patient_id AND hr.rn = 1
WHERE 1=1
";
$params = [];
if (search) {
sql .= " AND (p.name LIKE ? OR pl.username LIKE ? OR p.id LIKE ? OR p.phone LIKE ? OR p.email LIKE ?)";
searchparam="search%";
params=arraymerge(params, [searchparam,search_param, searchparam,search_param, $search_param]);
}
if (gender) {
sql .= " AND p.gender = ?";
params[]=gender;
}
if (min_age) {
sql .= " AND p.age >= ?";
params[]=min_age;
}
if (max_age) {
sql .= " AND p.age <= ?";
params[]=max_age;
}
if (status) {
sql .= " AND p.status = ?";
params[]=status;
}
// Note: Sorting will be handled client-side by DataTables
// Get all possible status options
$status_options = [
'Initial Consultation', 'Diagnostic Phase', 'Treatment in Progress', 'Improving',
'Monitoring', 'Maintenance Phase', 'Awaiting Test Results', 'Follow-up Needed',
'Paused', 'Completed Program', 'Relapsed', 'Discontinued', 'Inactive'
];
// Fetch Data Analysis Data
// Fetch total number of patients
stmt=pdo->query("SELECT COUNT() FROM patients");
totalpatients=stmt->fetchColumn();
// Fetch recent registrations (last 30 days)
stmt=pdo->query("SELECT COUNT() FROM patients WHERE registration_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY)");
recentregistrations=stmt->fetchColumn();
// Fetch recent registrations (today)
stmt=pdo->query("SELECT COUNT() FROM patients WHERE DATE(registration_datetime) = CURDATE()");
todayregistrations=stmt->fetchColumn();
// Fetch total number of invoices
stpdo->query("SELECT COUNT() FROM invoices");
totalinvoices=stmt->fetchColumn();
// Fetch gender distribution
stmt=pdo->query("SELECT gender, COUNT() as count FROM patients GROUP BY gender");
genderdistribution=stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch age distribution
stmtpdo->query("
SELECT
CASE
WHEN age < 18 THEN 'Under 18'
WHEN age BETWEEN 18 AND 30 THEN '18-30'
WHEN age BETWEEN 31 AND 50 THEN '31-50'
WHEN age BETWEEN 51 AND 70 THEN '51-70'
ELSE 'Over 70'
END AS age_group,
COUNT() as count
FROM patients
GROUP BY age_group
");
agedistribution=stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch status distribution
stmt=pdo->query("SELECT status, COUNT(*) as count FROM patients GROUP BY status");
statusdistribution=stmt->fetchAll(PDO::FETCH_ASSOC);
?>
To achieve your objective of creating a file that displays the survey information for participants who filled out page 8 of the "longeva_health_journey" survey, we will create a PHP file within a folder called longeva_health_journey_answers. The script will fetch and display relevant data from the database similar to a dashboard page, including statistics and survey details.
Here's a step-by-step explanation and the complete PHP code to accomplish this:
Steps
Create the Folder and File:
We'll create a folder named longeva_health_journey_answers and place a PHP file within it, for instance, survey_info.php.
Include Header and Footer:
Include header and footer files to ensure your page is well-structured and consistent with the rest of your site.
Set Up Database Connection:
Connect to the database to retrieve patient survey data.
Fetch Data:
Utilize SQL queries to gather data such as patient basic info and consultation details for patients who completed page 8 of the survey.
Display Data:
Present the fetched data in a structured manner, potentially using tables or statistics to show insights.
PHP Code for survey_info.php
<?php
// Include the header
include '../includes/header.php';
// Start session and include database connection
session_start();
require '../db_connect.php';
// Initialize variables
$patients = [];
$total_patients = 0;
$recent_registrations = 0;
$today_registrations = 0;
try {
// Fetch all patients who completed the page 8 survey
$sql = "
SELECT p.id, pb.name, pb.email, pb.phone, pb.gender, pb.age, pb.weight, pb.height, pc.scheduled_at
FROM patient_basic_info pb
JOIN patient_consultation pc ON pb.patient_id = pc.patient_id
JOIN patients p ON pb.patient_id = p.id
WHERE pc.scheduled_at IS NOT NULL
";
$stmt = $pdo->query($sql);
$patients = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch total number of patients
$stmt = $pdo->query("SELECT COUNT(*) FROM patients");
$total_patients = $stmt->fetchColumn();
// Fetch recent registrations (last 30 days)
$stmt = $pdo->query("SELECT COUNT(*) FROM patients WHERE registration_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY)");
$recent_registrations = $stmt->fetchColumn();
// Fetch recent registrations (today)
$stmt = $pdo->query("SELECT COUNT(*) FROM patients WHERE DATE(registration_datetime) = CURDATE()");
$today_registrations = $stmt->fetchColumn();
} catch (PDOException $e) {
echo "Database Error: " . $e->getMessage();
}
?>
<div class="container-fluid">
<h2 class="mb-3">Survey Information for Page 8 Completers</h2>
<div class="row g-3">
<div class="col-lg-4 col-md-6">
<div class="card h-100 text-center">
<div class="card-body">
<h5 class="card-title">Total Patients</h5>
<p class="card-text fs-4"><?= $total_patients ?></p>
</div>
</div>
</div>
<div class="col-lg-4 col-md-6">
<div class="card h-100 text-center">
<div class="card-body">
<h5 class="card-title">Registrations in Last 30 Days</h5>
<p class="card-text fs-4"><?= $recent_registrations ?></p>
</div>
</div>
</div>
<div class="col-lg-4 col-md-6">
<div class="card h-100 text-center">
<div class="card-body">
<h5 class="card-title">Registrations Today</h5>
<p class="card-text fs-4"><?= $today_registrations ?></p>
</div>
</div>
</div>
</div>
<h2 class="mt-5">Patient Data</h2>
<div class="table-responsive">
<table class="table table-bordered table-striped mt-3">
<thead>
<tr>
<th>Patient ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Gender</th>
<th>Age</th>
<th>Weight (kg)</th>
<th>Height (cm)</th>
<th>Consultation Date</th>
</tr>
</thead>
<tbody>
<?php foreach ($patients as $patient): ?>
<tr>
<td><?= htmlspecialchars($patient['id']) ?></td>
<td><?= htmlspecialchars($patient['name']) ?></td>
<td><?= htmlspecialchars($patient['email']) ?></td>
<td><?= htmlspecialchars($patient['phone']) ?></td>
<td><?= $patient['gender'] ?></td>
<td><?= $patient['age'] ?></td>
<td><?= $patient['weight'] ?></td>
<td><?= $patient['height'] ?></td>
<td><?= date('Y-m-d H:i', strtotime($patient['scheduled_at'])) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php
// Include the footer
include '../includes/footer.php';
?>
Explanation
Database Queries: The SQL statements are crafted to fetch relevant data about patients who completed the survey on page 8.
HTML Structure: We use Bootstrap classes (assuming it's included in your project) to style the table and card elements for a responsive layout.
Condition Handling: Implements error-handling measures in try-catch blocks for database operations to gracefully manage any exceptions.
Data Display: Utilizes loops to populate the table with patient details such as name, email, phone number, gender, etc.
This code will result in a webpage displaying both summary statistics and detailed information for patients who completed page 8 of the survey, formatted nicely for use within your admin dashboard setup. Ensure that paths to the header.php and footer.php are correct relative to your project's directory structure.
Certainly! Let's enhance the page to give it a more appealing design. Below, I've added a more elaborate design using Bootstrap classes and additional styling. I've also included some comments to guide you through the changes made.
Ensure you have Bootstrap integrated into your project to fully benefit from these styles.
Modern Card Layout for Statistics: Used Bootstrap cards with shadows for statistics at the top, providing a modern and clean look.
Styled Table: Enhanced the table with hover effects, a bordered style for better readability, and a primary color header.
Consistent Styling: Ensured color consistency by using Bootstrap's utility classes for text and backgrounds, making the UI cohesive.
Additional Notes
Header and Footer: Ensure that your header.php and footer.php files include necessary Bootstrap CSS and JavaScript.
Responsive Design: The use of Bootstrap grid and table classes ensures the page is responsive, adapting to different screen sizes.
Error Handling: Display a Bootstrap alert if there's a database connection error, providing a user-friendly message.
This setup will give your page a professional look and is easy to expand upon for additional features or data visualizations. Let me know if you need further customization or additional features!