在使用POST方法获取页面上的获取值后,如何使用过滤器A-Z进行排序



用户首先搜索指定的"医生";在,它重定向到";search.php";页然后显示数据库中的结果。我想要的是,当用户看到结果时,对它们进行排序;A-Z";。如果您还需要用户搜索";指定的医生我会张贴它,只是认为你不需要它:(

<?php
include 'models/doctors.class.php';
// error_reporting(0);
$search = new doctors();
if(isset($_POST['submit'])){
$s= $search->filterDoctors($_POST);
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="assets/css/search.css">
<link rel="stylesheet" href="assets/css/sanascout-font.css">
<link rel="icon" type="image/png" href="assets/images/logo-ssc1.png">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<title>Healthcare</title>
</head>
<body>
<!-- <section>
<div class="container-fluid firstSectionn">
<div class="popins-font">
<p class="searchHere text-center"><i class="bi bi-arrow-left-short pull-left"></i>Zürich <i class="bi bi-chat-dots pull-right"></i></p>
</div>
</div> -->
<section>
<div class="container-fluid thisContainerBGColor popins-font">
<div class="row">
<div class="col text-center pt-4 pb-3">
<a href="#" onclick="history.go(-1)" class="text-decoration-none text-light"> <i
class="bi bi-arrow-left-short"></i></a>
</div>
<div class="col text-center lh-1 pt-3 pb-3">
<span class="span-selected-area">Selected area</span> <br>
<span class="span-place">
<?php
$i = 0;
foreach($s as $row){
echo $row['location'];
$i++;
if($i == 1){
break;
}
}
?>
</span>
</div>

<div class="col text-center pt-4 pb-3">
<!-- <i class="bi bi-chat-dots"></i> -->
</div>
</div>
</div>
</section>
</section>
<section>
<section class="searched-area mt-4">
<div class="container">
<div class="header66">
<div style="display: flex; justify-content: space-between;">
<p class="fs-6 popins-font fw-bold" id="text-color">Available Doctors</p>
<!-- <a href="#" class="text-decoration-none">
<p class="fs-6 popins-font fw-bold" id="text-color">See all</p>
</a> -->
</div>
</div>
</div>
</section>
<a href="#" class="btn btn-primary">Filter-A-Z</a>
<div>
<?php
if(isset($_SESSION['msg'])){
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
</div>
<section>
<div class="container">
<?php
foreach($s as $row1){
?>
<a href="therapist.php?id=<?php echo $row1['User_ID']; ?>" class="text-decoration-none">
<div class="therapistCardOne mx-2 popins-font my-2">
<div class="row py-2">
<div class="col-3 g-0">
<div class="imgW text-center g-0 ps-2">
<img src="assets/images/006.png" class="img-fluid ms-2" alt="" width="70px"
height="80px">
</div>
</div>
<div class="col-8 g-0 ps-2">
<span class="span1"><?php echo $row1['full_name'];?></span>
<span class="ps-2">
<i class="bi bi-star-fill icon-ccc"></i>
<i class="bi bi-star-fill icon-ccc"></i>
<i class="bi bi-star-fill icon-ccc"></i>
<i class="bi bi-star-fill icon-ccc"></i>
<i class="bi bi-star icon-ccc"></i></span><br>
<span class="span2">Location :
<?php echo $row1['location'];?>
</span> <br>
<span class="span3"><i class="bi bi-clock icon-cc"></i> 12:00pm - 16:00pm</span> <span
class="span4 ps-2"><i class="bi bi-geo-alt icon-cc"></i> Zurich New Clinic</span>
</div>
<div class="col-1 g-0 pe-2">
<i class="bi bi-three-dots-vertical"></i>
</div>
</div>
</div>
</a>
<?php 
}
}
else {
header("Location:therapist-list.php");
}
?>
</section>

您可以使用ajax和php函数

在search.php中创建一个表单然后保存你用来重定向到search.php的帖子,并使用php函数对医生进行排序。

最新更新