この Web ページをしばらく機能させようとしてきましたが、問題が発生し続けています。この Web ページには、選択を行い、フィルターを適用してクエリを作成するための一連の選択ボックス (独立しているものと、別のものに依存しているものがあります) があります。まだテストモードであり、単一の選択に対しては正常に機能しています。しかし、私はまだ同じ選択ボックスで複数の選択を行うことができませんでした. 例えば; 地域ボックスでヨーロッパと北アメリカを選択してフィルターを適用すると、ヨーロッパまたは北アメリカにある企業の結果が得られるはずなのに、結果が得られません。テスト Web ページはこちらにあります: http://golevler.awardspace.biz/realdeal04.html
.PHP ファイルで "implode" と IN 演算子を使用しようとしましたが、どこで間違っているのかわかりません。よろしければ、正しい方法を教えていただければ幸いです。以下のコーディングを見つけることができます:
PHP
<?php
error_reporting(E_ALL); ini_set('display_errors', 1); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$DB_HOST = "*****"; $DB_USER = "*****"; $DB_PASS = "*****"; $DB_NAME = "*******";
$con = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); if($con->connect_errno > 0) { die('Connection failed [' . $con->connect_error . ']'); }
$bolge= "'" . implode("', '", $_POST['filtre_region']) . "'" ;
$bolge1= mysqli_real_escape_string($con,$bolge);
$ulke= "'" . implode("', '", $_POST['filtre_country']) . "'";
$ulke1= mysqli_real_escape_string($con,$ulke);
$sektor= "'" . implode("', '", $_POST['filtre_sector']) . "'";
$sektor1= mysqli_real_escape_string($con,$sektor);
$altsektor= "'" . implode("', '", $_POST['filtre_subsector']) . "'";
$altsektor1= mysqli_real_escape_string($con,$altsektor);;
$urun= "'" . implode("', '", $_POST['filtre_product']) . "'";
$urun1= mysqli_real_escape_string($con,$urun);
$sql = mysqli_query("SELECT * FROM gorevler WHERE region IN ('$bolge1') AND country IN ('$ulke1') AND sector IN ('$sektor1') AND sub_sector IN ('$altsektor1') AND product IN ('$urun1')");
echo "<table border='0'>
<tr>
<th>No</th>
<th>Company</th>
<th>Region</th>
<th>Country</th>
<th>Sector</th>
<th>Sub Sector</th>
<th>Product</th>
<th>Website</th>
</tr>";
while ($row = mysqli_fetch_array($sql)){
echo "<td>" . ''.$row['no'] . "</td>";
echo "<td>" . ''.$row['company'] . "</td>";
echo "<td>" . ''.$row['region'] . "</td>";
echo "<td>" . ''.$row['country'] . "</td>";
echo "<td>" . ''.$row['sector'] . "</td>";
echo "<td>" . ''.$row['sub_sector'] . "</td>";
echo "<td>" . ''.$row['product'] . "</td>";
echo "<td>" . ''.$row['website'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
HTML
<form id="filtersForm" action="search_company.php" method="post" target="_blank">
<fieldset id="filtersPane">
<div class="part03_line01" id="part03_line01">
<div class="filter_bolge" id="filtre_bolge"><p>Region:</p>
<select id="filter_region" name="filtre_region[]" class="select_bolge" title="Select a region" multiple="multiple" size="5">
</select>
</div>
<div class="filter_ulke" id="filtre_ulke"><p>Country:</p>
<select id="filter_country" name="filtre_country[]" class="select_ulke" title="Select a country" multiple="multiple" size="5">
</select>
</div>
<div class="filter_sektor" id="filtre_sektor"><p>Sector:</p>
<select id="filter_sector" name="filtre_sector[]" class="select_sektor" title="Select a sector" multiple="multiple" size="5">
</select>
</div>
<div class="filter_altsektor" id="filtre_altsektor"><p>Sub Sector:</p>
<select id="filter_subsector" name="filtre_subsector[]" disabled="disabled" class="select_altsektor" title="Select a sub-sector" multiple="multiple" size="5">
<option value="" data-filter-type="" selected="selected">
-- Make a Choice --</option>
</select>
</div>
<div class="filter_urun" id="filtre_urun"><p>Product:</p>
<select id="filter_product" name="filtre_product[]" disabled="disabled" class="select_urun" title="Select a product" multiple="multiple" size="5">
<option value="" data-filter-type="" selected="selected">
-- Make a Choice --</option>
</select>
</div>
</div>
<div class="part03_line03" id="part03_line03">
<div class="aramadugmesi" id="aramadugmesi"> <button type="submit" id="applyFilterButton">Apply Filters</button>
</div>
</div>
</fieldset>
</form>
ジャバスクリプト
<script>
$(document).ready(function() {
$('#filter_region')
.load('/textdata/region.txt');
$('#filter_country')
.load('/textdata/country.txt');
$('#filter_sector')
.load('/textdata/sector.txt');
$('#filter_sector').change(function() {
$('#filter_subsector').load("textdata/subsector/" + $(this).val() + ".txt",
function(){
$(this).attr('disabled',false);
}
);
});
$('#filter_subsector').change(function(){
$('#filter_product').load(
"textdata/subsector/product/" + $(this).val() + ".txt",
function(){
$(this).attr('disabled',false);
}
);
});
});
</script>
この Php コーディングはうまくいきません。[フィルターの適用] をクリックしても結果が得られません。たとえば、選択ボックスでヨーロッパと北アメリカを選択して [適用] をクリックすると、ヨーロッパまたは北アメリカにあるすべての企業がデータベースから取得され、一覧表示されます。しかし、結果は得られません。PHPコーディングの問題だと思いますが、何が悪いのかわかりません