0

I'm adapting a WordPress plugin for use on a recruitment agency website.

http://mjtweaverdev.com/jobs/?job_industry=null&job_salary=10000

However, the client needs a select option that goes inbetween two values, for instance 10000-19000. I've tried multiple things but cant get it working.

I've tried &job_salary=10000, 11000, 12000 .... that didnt work also &job_salary=10000&job_salary=11000&job_salary=12000 - that just selected the last option

Is there any way of querying two values so 10000-19000 in the query?

UPDATE: I'm trying the first recommended method, below is the code from the plugin I've tried to tweak, it still isnt working though :/ http://jsfiddle.net/mjtweaver/9ga6u/

4
  • whts unclear in this ??? can u get multiple values from single variable?? by asssgning diff vlues?? Commented Apr 20, 2014 at 10:46
  • Since you want a range (between some salary range), add FROM and TO salary in URL and use them in your query (using BETWEEN clause). Commented Apr 20, 2014 at 10:51
  • @AshishRatan im sorry i dont follow you at all. Commented Apr 20, 2014 at 11:13
  • @MichaelWeaver JSFiddle don't execute PHP scripts. Commented Apr 20, 2014 at 11:35

2 Answers 2

3

Well you can use [] to treat them as array:

job_salary[]=10000&job_salary[]=11000&job_salary[]=12000

Doing var_dump:

var_dump($_GET['job_salary']);

Output:

array (size=3)
  0 => string '10000' (length=5)
  1 => string '11000' (length=5)
  2 => string '12000' (length=5)
Sign up to request clarification or add additional context in comments.

2 Comments

But he wants between viz. 10000-19000. Then why not use to-from only and use BETWEEN in query.
@ParagTyagi I'm just giving an alternative way.
2

Try this -

http://mjtweaverdev.com/jobs/?job_industry=null&job_salary_from=10000&job_salary_to=19000


Your PHP script -

<?php

$job_salary_from = $_GET['job_salary_from'];
$job_salary_to = $_GET['job_salary_to'];

$sql = "SELECT * FROM table_name WHERE 
       salary BETWEEN $job_salary_from AND $job_salary_to";

1 Comment

I'm trying to do this, im editing the plugin now, this is what I have but it still isnt working :/ jsfiddle.net/mjtweaver/9ga6u

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.