filter option working along with search did some

spelling changes to in the managejob php
main
Grim0o5 6 months ago
parent e6bc17cdc3
commit 68f89bb42d
  1. 74
      index.php
  2. 6
      managejob.php
  3. 98
      search_results.php

@ -16,22 +16,30 @@
<div class="absolute inset-0 bg-grid-slate-900/[0.04] bg-[size:40px_40px]"></div>
<div class="hero-content text-center">
<div class="max-w-xl relative z-10">
<h1 class="text-5xl font-bold mb-8 bg-clip-text text-transparent bg-gradient-to-r from-primary to-secondary">
<h1
class="text-5xl font-bold mb-8 bg-clip-text text-transparent bg-gradient-to-r from-primary to-secondary">
The Future of Work
</h1>
<p class="py-6 text-lg">Discover opportunities that match your schedule and skills in real-time.</p>
<form action="search_results.php" method="GET" class="join w-full backdrop-blur-sm bg-base-100/50 rounded-lg p-1">
<form action="search_results.php" method="GET"
class="join w-full backdrop-blur-sm bg-base-100/50 rounded-lg p-1">
<input name="search" class="input join-item flex-1 !outline-none border-primary/20"
placeholder="Search for jobs..." value="<?php echo isset($_GET['search']) ? htmlspecialchars($_GET['search']) : ''; ?>" />
placeholder="Search for jobs..."
value="<?php echo isset($_GET['search']) ? htmlspecialchars($_GET['search']) : ''; ?>" />
<button type="submit" class="btn join-item btn-primary">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
</button>
<button type="button" class="btn join-item" onclick="document.getElementById('filter_modal').showModal()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" />
<button type="button" class="btn join-item"
onclick="document.getElementById('filter_modal').showModal()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" />
</svg>
</button>
</form>
@ -84,59 +92,69 @@
<dialog id="filter_modal" class="modal modal-bottom sm:modal-middle">
<form method="dialog" class="modal-box bg-base-200">
<form action="search_results.php" method="GET" class="modal-box bg-base-200">
<!-- Preserve search term -->
<input type="hidden" name="search" value="<?php echo isset($_GET['search']) ? htmlspecialchars($_GET['search']) : ''; ?>">
<h3 class="font-bold text-lg mb-4">Filter Options</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="form-control w-full">
<label class="label">
<span class="label-text">Job Type</span>
</label>
<select class="select select-bordered">
<select name="job_type" class="select select-bordered">
<option value="">Select Type</option>
<option value="childcare">childcare and petcare</option>
<option value="cleaning">cleaning and maintainence</option>
<option value="delivery">delivery and logistics</option>
<option value="seasonal">Seasonal</option>
<option value="Childcare and Petcare" <?php echo (isset($_GET['job_type']) && $_GET['job_type'] == 'Childcare and Petcare') ? 'selected' : ''; ?>>Childcare and Petcare</option>
<option value="Cleaning and Maintenance" <?php echo (isset($_GET['job_type']) && $_GET['job_type'] == '"Cleaning and Maintenance') ? 'selected' : ''; ?>>Cleaning and Maintenance</option>
<option value="Delivery and Logistics" <?php echo (isset($_GET['job_type']) && $_GET['job_type'] == 'Delivery and Logistics') ? 'selected' : ''; ?>>Delivery and Logistics</option>
<option value="Seasonal" <?php echo (isset($_GET['job_type']) && $_GET['job_type'] == 'Seasonal') ? 'selected' : ''; ?>>Seasonal</option>
</select>
</div>
<div class="form-control w-full">
<label class="label">
<span class="label-text">Salary type</span>
<span class="label-text">Salary Type</span>
</label>
<select class="select select-bordered">
<select name="salary_type" class="select select-bordered">
<option value="">Select Range</option>
<option value="Hourly">Hourly</option>
<option value="Daily">Daily</option>
<option value="Hourly" <?php echo (isset($_GET['salary_type']) && $_GET['salary_type'] == 'Hourly') ? 'selected' : ''; ?>>Hourly</option>
<option value="Daily" <?php echo (isset($_GET['salary_type']) && $_GET['salary_type'] == 'Daily') ? 'selected' : ''; ?>>Daily</option>
</select>
</div>
<div class="form-control w-full">
<label class="label">
<span class="label-text">skills level</span>
<span class="label-text">Skills Level</span>
</label>
<select class="select select-bordered">
<select name="skill_level" class="select select-bordered">
<option value="">Select Level</option>
<option value="entry">Entry Level</option>
<option value="intermediate">Intermediate</option>
<option value="experienced">Experienced</option>
<option value="Entry Level" <?php echo (isset($_GET['skill_level']) && $_GET['skills_level'] == 'entry') ? 'selected' : ''; ?>>Entry Level</option>
<option value="Intermediate" <?php echo (isset($_GET['skill_level']) && $_GET['skills_level'] == 'intermediate') ? 'selected' : ''; ?>>Intermediate</option>
<option value="Experienced" <?php echo (isset($_GET['skill_level']) && $_GET['skills_level'] == 'experienced') ? 'selected' : ''; ?>>Experienced</option>
</select>
</div>
</div>
<div class="modal-action">
<button class="btn btn-ghost">Reset</button>
<button class="btn btn-primary">Apply Filters</button>
<button type="button" class="btn btn-ghost" onclick="resetFilters(this.form)">Reset</button>
<button type="submit" class="btn btn-primary">Apply Filters</button>
</div>
</form>
<form method="dialog" class="modal-backdrop">
<button>close</button>
</form>
</dialog>
<script>
function resetFilters(form) {
// Preserve the search term while resetting other fields
const searchValue = form.querySelector('input[name="search"]').value;
form.reset();
form.querySelector('input[name="search"]').value = searchValue;
}
</script>
<div class="container mx-auto p-8">
<h2 class="text-3xl font-bold mb-8 text-center">How It Works</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">

@ -162,9 +162,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['job_title'])) {
</label>
<select class="select select-bordered w-full max-w-xs" name="job_type" >
<option disabled selected>Select Type</option>
<option>childcare and petcare</option>
<option>cleaning and maintainence</option>
<option>delivery and logistics</option>
<option>Childcare and Petcare</option>
<option>Cleaning and Maintenance</option>
<option>Delivery and Logistics</option>
<option>Seasonal</option>
</select>
</div>

@ -4,65 +4,68 @@ include 'connect.php';
// Check if the user is logged in
if (!isset($_SESSION['email'])) {
// If not logged in, redirect to login page
header("Location: login.php");
exit();
}
// Build the SQL query based on search parameters
$where_conditions = array();
$params = array();
try {
// Initialize arrays for query building
$where_conditions = [];
$params = [];
$types = "";
// Search by job title or description
if (!empty($_GET['search'])) {
$where_conditions[] = "(job_title LIKE ? OR description LIKE ?)";
$where_conditions[] = "(job_title LIKE ? OR job_description LIKE ?)";
$search_term = "%" . $_GET['search'] . "%";
$params[] = $search_term;
$params[] = $search_term;
$types .= "ss";
}
// Search by location
if (!empty($_GET['location'])) {
$where_conditions[] = "location = ?";
$params[] = $_GET['location'];
$types .= "s";
}
// Search by job type
// Job type filter
if (!empty($_GET['job_type'])) {
$where_conditions[] = "job_type = ?";
$params[] = $_GET['job_type'];
$types .= "s";
}
// Search by salary type
// Salary type filter
if (!empty($_GET['salary_type'])) {
$where_conditions[] = "salary LIKE ?";
$params[] = "%" . $_GET['salary_type'] . "%";
$where_conditions[] = "salary_type = ?"; // Changed to match the exact column name
$params[] = $_GET['salary_type'];
$types .= "s";
}
// Search by skill level
if (!empty($_GET['skill_level'])) {
$where_conditions[] = "skill_level = ?";
$params[] = $_GET['skill_level'];
// Skills level filter
if (!empty($_GET['skills_level'])) {
$where_conditions[] = "skills_level = ?";
$params[] = $_GET['skills_level'];
$types .= "s";
}
// Construct the SQL query
$sql = "SELECT * FROM job_postings";
// Add WHERE clause if there are conditions
if (!empty($where_conditions)) {
$sql .= " WHERE " . implode(" AND ", $where_conditions);
}
// Add ordering
$sql .= " ORDER BY posted_date DESC";
// Prepare and execute the query
$stmt = $conn->prepare($sql);
if (!empty($params)) {
$stmt->bind_param($types, ...$params);
}
?>
$stmt->execute();
$result = $stmt->get_result();
?>
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
@ -85,10 +88,7 @@ if (!empty($params)) {
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<?php
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
if ($result && $result->num_rows > 0) {
while ($job = $result->fetch_assoc()) {
?>
<div class="lg:col-span-1">
@ -97,6 +97,7 @@ if (!empty($params)) {
<h2 class="card-title text-xl mb-4"><?= htmlspecialchars($job['job_title']) ?></h2>
<div class="space-y-4">
<!-- Location -->
<div class="flex items-center gap-3">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-primary" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z" clip-rule="evenodd" />
@ -107,26 +108,38 @@ if (!empty($params)) {
</div>
</div>
<!-- Salary and Type -->
<div class="flex items-center gap-3">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-primary" viewBox="0 0 20 20" fill="currentColor">
<path d="M8.433 7.418c.155-.103.346-.196.567-.267v1.698a2.305 2.305 0 01-.567-.267C8.07 8.34 8 8.114 8 8c0-.114.07-.34.433-.582zM11 12.849v-1.698c.22.071.412.164.567.267.364.243.433.468.433.582 0 .114-.07.34-.433.582a2.305 2.305 0 01-.567.267z" />
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-13a1 1 0 10-2 0v.092a4.535 4.535 0 00-1.676.662C6.602 6.234 6 7.009 6 8c0 .99.602 1.765 1.324 2.246.48.32 1.054.545 1.676.662v1.941c-.391-.127-.68-.317-.843-.504a1 1 0 10-1.51 1.31c.562.649 1.413 1.076 2.353 1.253V15a1 1 0 102 0v-.092a4.535 4.535 0 001.676-.662C13.398 13.766" />
</svg>
<div>
<div class="text-sm opacity-70">Salary</div>
<div class="text-sm opacity-70">Salary (<?= htmlspecialchars($job['salary_type']) ?>)</div>
<div class="font-medium"><?= htmlspecialchars($job['salary']) ?></div>
</div>
</div>
<!-- Job Type -->
<div class="flex items-center gap-3">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-primary" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd" />
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 13.255A23.931 23.931 0 0112 15c-3.183 0-6.22-.62-9-1.745M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2 2v2m4 6h.01M5 20h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
</svg>
<div>
<div class="text-sm opacity-70">Posted Date</div>
<div class="font-medium"><?= date('F j, Y', strtotime($job['posted_date'])) ?></div>
<div class="text-sm opacity-70">Job Type</div>
<div class="font-medium"><?= htmlspecialchars($job['job_type']) ?></div>
</div>
</div>
<!-- Skills Level -->
<div class="flex items-center gap-3">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" />
</svg>
<div>
<div class="text-sm opacity-70">Required Skills</div>
<div class="font-medium"><?= htmlspecialchars($job['skills_level']) ?></div>
</div>
</div>
<div class="divider"></div>
@ -137,17 +150,36 @@ if (!empty($params)) {
</div>
</div>
</div>
</div>
<?php
}
} else {
echo "<p>No jobs available.</p>";
echo "<div class='lg:col-span-3 text-center p-8 bg-base-100 rounded-lg shadow-xl'>";
echo "<h3 class='text-xl font-bold mb-2'>No Jobs Found</h3>";
echo "<p>Try adjusting your search criteria or removing some filters.</p>";
echo "</div>";
}
$conn->close();
?>
</div>
</main>
<?php include 'footer.php'; ?>
</body>
</html>
<?php
} catch (Exception $e) {
echo "<div class='container mx-auto px-4 py-8'>";
echo "<div class='alert alert-error'>";
echo "Error details: " . htmlspecialchars($e->getMessage());
echo "</div>";
echo "</div>";
}
// Close database connections
if (isset($stmt)) {
$stmt->close();
}
if (isset($conn)) {
$conn->close();
}
?>
Loading…
Cancel
Save