How to filter records by date using a slider-bar?

Hello again,

I would like to add a slider-bar to my site on which to filter markers retrieved from my database, by date (YEAR).

The following SQL query returns the distinct YEARS for which i have records - each of which i would like to be a notch on my slider:
$query_years = mysql_query("Select distinct YEAR(date) from locations order by date");

I asked the following question "How do i add increments to my slider" - which mplungian answered:

Now i need to know...

1. How do i add the distinct years from the SQL query as increments to my slider - please can you show me how this is done?

2. How do i set each increment to only return records from the corresponding year - e.g.
"SELECT * FROM locations WHERE YEAR(date) = date"

I suspect that i will need to disable my current database queries while the slider is in use. Ideally the first  (default) notch on the slider would display all records/markers.

Any help and advice greatly appreciated
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could first have a query:

$query = 'SELECT DISTINCT YEAR(date) FROM locations';

$res = mysql_query($query) or trigger_error("There was an error in $query: " . mysql_error());

$years = array();
while($row = mysql_fetch_array($res)) {
  $years[] = $row[0];

From the results of this you can extract the min and max and even separate increments. However, you might not want to skip any years in your slider as that might confuse users anyhow.

echo 's.Minimum = ' . min($years).';';
echo 's.Maximum = ' . max($years).';';
DaniishAuthor Commented:
I intend on displaying a message to say which year of records is being displayed - so hopefully that will prevent users being confused.

Can you tell me how i can extend:

>>     echo 's.Minimum = ' . min($years).';';
>>     echo 's.Maximum = ' . max($years).';';

- to display each distinct year as an individual increment ?

I'm not sure what you mean by "each distinct year as an individual increment" (I'm not native english, which might be part of the problem).

Do you mean a slider which just has has values 2005,2006,2009 when only these three years are available?
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

DaniishAuthor Commented:
Yes you're right that's what i mean.

For instance i would like the results of this query to form the slider values:
$query_years = mysql_query("Select distinct YEAR(date) from locations order by date");
As far from the slider documentation, this is not supported. I cannot find an alternative slider type inside the webfx widgets list that supports this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DaniishAuthor Commented:
Oh dear. Do you know of any alternative slider that would support this?
DaniishAuthor Commented:
Well in so much as you have identified its not possible i now need to close this question and award you for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.