mysqli - SQL: show 20m less and 20m more of searched term -


i have following:

$p['int_length_min'] = 'products.length'; $p['int_length_max'] = 'products.length';  if (!empty($params['int_length_min']) && !empty($params['int_length_max'])) {     $query .= db_quote(' , int_length > ( ?i - 20 ) , int_length <= ?i ', $params['int_length_min'], $params['int_length_max']); } 

not sure how convert following: instead of having 2 fields, have 1, , when user enters number, - / + 20, example if user enter 100, return results 80 - 120. tried adding (?i + 20) in statement never got back, below:

$p['int_length_m'] = 'products.length';  if (!empty($params['int_length_m'])) {     $query .= db_quote(' , int_length > ( ?i - 20 ) , int_length <= ( ?i + 20) ', $params['int_length_m']); } 

any ideas?

thanks.

to have one parameter filters on range, use yoda between:

... , ?i between int_length - 20 , int_length + 20 ... 

or in code:

$query .= db_quote(' , ?i between int_length - 20 , int_length + 20', $params['int_length_m']); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -