例... ">" より大きいオプションが選択されていても、このクエリは表示されます
SELECT *
FROM sr_rounds
WHERE cir1 LIKE '%2.4%'
ORDER BY sr_id asc
何か案は?
<form action="search_new.php" method="post" name="exchanges" id="exchanges">
<select name="circuits" id="circuits" onclick="searchIt()" onblur="searchIt()">
<option value="select" selected="selected">Select Search Field</option>
<option value="cir1">Circuit 1</option>
<option value="cir2">Circuit 2</option>
<option value="cir3">Circuit 3</option>
<option value="cir4">Circuit 4</option>
<option value="vch">VCH-1-5</option>
</select>
<select name="sorting" id="sorting" onclick="searchIt()" onblur="searchIt()">
<option value="select1" selected="selected">Sort By</option>
<option value="sr_id">Sector</option>
<option value="date">Date</option>
//This select always returns a "like" clause regardless of which option you select
</select>
<select name="clauses" id="clauses" onclick="searchIt()" onblur="searchIt()">
<option value="select2" selected="selected">Clause</option>
<option value="=">Equals</option>
<option value="like">Like</option>
<option value=">">Greater Than</option>
<option value="<">Less Than</option>
<option value="date">Date</option>
</select>
<select name="sortorder" id="sortorder" onclick="searchIt()" onblur="searchIt()">
<option value="select3" selected="selected">Order</option>
<option value="asc" name="1">Asc</option>
<option value="desc" name="2">Desc</option>
</select>
<?php
$select = $_POST['circuits'];
$searchdb = $_POST['searchdb'];
$select1 = $_POST['sorting'];
$select2 = $_POST['clauses'];
$select3 = $_POST['sortorder'];
//To display friendly field name instead of actual field name
if ($select == 'cir1')
{
$boxresult = 'Circuit 1';
}
if ($select == 'cir2')
{
$boxresult = 'Circuit 2';
}
if ($select == 'cir3')
{
$boxresult = 'Circuit 3';
}
if ($select == 'cir4')
{
$boxresult = 'Circuit 4';
}
if ($select == 'vch')
{
$boxresult = 'VCH-1-5';
}
//To use different queries while searching
if ($select2 == '=')
{
$queres = "SELECT * FROM sr_rounds WHERE $select = '$searchdb' ORDER BY $select1 $select3";
}
else if ($select2 == 'like')
{
$queres = "SELECT * FROM sr_rounds WHERE $select LIKE '$searchdb' ORDER BY $select1 $select3";
}
else if ($select2 == '>')
{
$queres = "SELECT * FROM sr_rounds WHERE $select > '$searchdb' ORDER BY $select1 $select3";
}
else if ($select2 == '<')
{
$queres = "SELECT * FROM sr_rounds WHERE $select < '$searchdb' ORDER BY $select1 $select3";
}
else if ($select2 == 'contain');
{
$queres = "SELECT * FROM sr_rounds WHERE $select LIKE '%$searchdb%' ORDER BY $select1 $select3";
}
$query = $queres;
$result = @mysql_query($query);
$num = @mysql_num_rows($result);