私はこのコードを使用して、自分のWebサイトにいくつかの紹介文を表示しています。
これはこれまでのコードです:
// Select testimonials from database
$q = "SELECT testimonial, city_name, name, web_address, image_name, membership_type
FROM testimonials
INNER JOIN city ON city.city_id = testimonials.city_id
ORDER BY date_added DESC LIMIT $start, $display";
$r = mysqli_query($dbc, $q);
if ( $records >= 1 ) {
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'];
echo '<div class="testimonial-row">
<div class="testimonial-image">
<img src="'.UPLOAD_DIR.$imageName.'" />
</div>
<div class="testimonial">
<h2>'.$name.'</h2>
<h3>';
if($type==1){
echo 'A teacher';
}elseif($type==2){
echo 'An Institute';
}elseif($type==3){
echo 'A Student';
}
echo " from <strong>$city</strong></h3>
<blockquote>$mytestimonial</blockquote>
<p class='user-url'><a href=''>$url</a></p>
</div>
</div>";
}
} else {
echo "There is no any testimonial to display at this time. Please try again later.";
}
上記のコードを実行した後、すべての証言を表示できます。私は3種類の紹介文を持っており、現時点ではすべての種類の紹介文を一緒にページに表示しています。
次に、タイプに応じてフィルタリングして表示するための選択ボックスを使用したソリューションを実行します。
これは私の選択ボックスです:
<select class="select" name="type">
<option value="1">Tutor</option>
<option value="2">Institute</option>
<option value="3">Student</option>
</select>
選択ボックスからオプションを選択すると、選択したタイプで元のクエリを再クエリすることでフィルタリングが発生するはずです。jqueryの表示/非表示関数を使用して解決策を取得しましたが、目的の結果と一致しません。
注:この選択ボックスで送信ボタンを使用することはできません。そのため、AjaxまたはJqueryを使用したソリューションを探しています。
誰かが私にそれが可能かどうか教えてもらえますか?
ありがとうございました。