mvp.7
This commit is contained in:
parent
dddb7eeaf5
commit
c1f814ac1a
21
index.php
21
index.php
@ -3,9 +3,19 @@ require_once 'db/config.php';
|
||||
|
||||
// Fetch all processes from the database
|
||||
$processes = [];
|
||||
$search_query = $_GET['search'] ?? '';
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query("SELECT id, name, description, created_at FROM processes ORDER BY created_at DESC");
|
||||
$sql = "SELECT id, name, description, created_at FROM processes";
|
||||
if (!empty($search_query)) {
|
||||
$sql .= " WHERE name LIKE :search_query OR description LIKE :search_query";
|
||||
}
|
||||
$sql .= " ORDER BY created_at DESC";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
if (!empty($search_query)) {
|
||||
$stmt->bindValue(':search_query', '%' . $search_query . '%', PDO::PARAM_STR);
|
||||
}
|
||||
$stmt->execute();
|
||||
$processes = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
// Silently log error, or display a friendly message.
|
||||
@ -124,6 +134,15 @@ $project_image_url = htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '');
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body p-4">
|
||||
<h2 class="h4 card-title fw-bold">Existing Processes</h2>
|
||||
<form action="index.php" method="GET" class="mb-4">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Search by name or description" name="search" value="<?php echo htmlspecialchars($_GET['search'] ?? ''); ?>">
|
||||
<button class="btn btn-outline-secondary" type="submit" id="button-search">Search</button>
|
||||
<?php if (isset($_GET['search'])): ?>
|
||||
<a href="index.php" class="btn btn-outline-secondary" type="button">Clear</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
<?php if (empty($processes)): ?>
|
||||
<div class="text-center py-5">
|
||||
<i data-feather="search" class="text-muted mb-3" style="width: 48px; height: 48px;"></i>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user