辞書を作成していて、ユーザーが取得できる結果の数を制限したいと考えています。私の HTML ページには、ユーザーが制限できる検索範囲を定義する一連のラジオ ボタンがあります。1 = シンプル、2 = 簡単、3 = 普通、4 = 難しい、7 = すべて。これは、エントリに添付されたデータベース値、難易度によって定義されます。次のコードで検索を制限しようとしていますが、結果が返されません。$search_limit はラジオの値です。
if(strcmp($search_limit, '1'))
{
$sql .= ') and (Difficulty is null or Difficulty = 1) and rownum<=500' . $search_order;
}
elseif (strcmp($search_limit, '2'))
{
$sql .= ') and (Difficulty >= 1 or Difficulty <= 3) and rownum<=500' . $search_order;
}
elseif (strcmp($search_limit, '3'))
{
$sql .= ') and (Difficulty >= 4 or Difficulty <= 6) and rownum<=500' . $search_order;
}
else
{
$sql .= ') and (Difficulty <= 7) or rownum<=500' . $search_order;
}
私が問題を抱えているのは、(難易度 >= x または難易度 <= x) です。検索制限をelseステートメントにデフォルト設定すると、難易度7(最大)以下のすべてが正しく返されます。同様に、else ステートメントの 7 を 7 未満の他の数字に置き換えても、正しく機能します。定義された検索を機能させることができません。