我正在尝试将我的 SQL 查询更改为使用 BETWEEN 搜索/比较 LIKE 以从特定字段中获取 >= 搜索值的所有值......到目前为止无法使其工作。
$searchcat = "brand";
if (isset($_POST['searchcat'])) {
$searchcat = $_POST['searchcat'];
}
$selectVal = "LIKE %s";
if ($searchcat == 'quantity') {
$selectVal = "BETWEEN %s";
}else{
$selectVal == "LIKE %s";
}
mysql_select_db($database_prp, $prp);
$query_paperlist = sprintf("SELECT * FROM paperlist WHERE $searchcat $selectVal ORDER BY paperid ASC", GetSQLValueString("%" . $colname_paperlist . "%", "text"));
$query_limit_paperlist = sprintf("%s LIMIT %d, %d", $query_paperlist, $startRow_paperlist, $maxRows_paperlist);
$paperlist = mysql_query($query_limit_paperlist, $prp) or die(mysql_error());
$row_paperlist = mysql_fetch_assoc($paperlist);