在我的网站上,我有一个页面来显示推荐。我写这段代码是为了显示我在数据库中的所有推荐。
到目前为止,这是我的代码:
while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC)) {
$testimonial = $row['testimonial'];
//echo $testimonial;
$mytestimonial = nl2br($testimonial);
$city = $row['city_name'];
$name = $row['name'];
$url = $row['web_address'];
$imageName = $row['image_name'];
$type = $row['membership_type'];
}
使用这段代码,我可以将我所有的推荐书放到页面上。它很适合我。我的问题是现在我需要根据类型过滤我的推荐。我的数据库中有 3 种不同的推荐。 (导师、学院、学生)
我将使用选择框来过滤数据。从选择框中选择一个选项时,我需要根据所选类型显示推荐。
<div class="filter-box">
<div id="select_box">
<form method="post" action="">
<div class="variation2">
<label>Filter By</label>
<select class="select">
<option>Tutor</option>
<option>Institute</option>
<option>Student</option>
</select>
</div>
</form>
</div>
</div>
谁能帮我指明方向?
谢谢
最佳答案
为什么不在用户选择 3 个选项之一并显示您所需的推荐后动态地重新加载选择框(使用 AJAX)。我想这会解决您的问题。
关于php - 从下拉选择中显示数据库内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15225213/