例......即使「>」,大於選項被選中一個選擇不發佈所選選項
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);
檢查您的形式被傳遞到正確的數據 - 你的價值觀可能會得到轉化成HTML實體 – andrewsi 2013-03-20 19:55:57
這是被傳遞什麼陣列 ( [電路] => CIR1 [排序] => sr_id [子句] => => [排序順序] => ASC(6){[「circuits」] => string(4)「cir1」[「sorting」] => string(5)「sr_id」 [「clauses」] => string(2)「=>」[「sortorder」] => string(3)「asc」[「searchdb」] => string(3)「2.4」[「submit」] =>字符串(6)「搜索」} – bech64 2013-03-20 20:00:49