I am wanting to do something similar to this:
http://www.dimarzio.com/pickup-picker
My question involves the concept rather than any specific code on how to execute this.
For example, we are selling violins and we want the user to input info about their playing style, and give them the three best violins based on their entry. This is the data I’ve been given:
So if the user inputs Expert, Hard, Rock, and Dark I will get data sets of violins consisting of: Cannon, Soil, Ysaye, K.Joseph, Heifetz // Cannon, Kreisler, Soil, Heifetz // Kreisler, Diable, Vieuxtemps // Cannon, Diable, Plowden
Out of those I need to output to the user the three best choices for them. Cannon is listed in 3 out of the 4, so that has to be #1. Now there are three more violins that match two of the four criteria. The Soil, Kriesler and Diable. In order to drill that down to two choices, I would think the questions would have to be ranked according to importance. For instance Tone is most important, followed by bowing style, musical genre, and skill level. Based on that ranking, the program should choose the Diable and Kreisler.
I am not entirely sure how to approach this. Since this data will not change frequently, should this even get the database involved? Should the info just be stored in a multi-dimensional array? Once the data is in an array, whether from the DB or not, how should I go about programming the logic to examine the arrays in order of importance and grab the violins that are most relevant?
Any help is much appreciated! I figured this was going to be easy, until I actually started thinking about it!
To me this sounds like a sorting problem. I don’t know anything about violins so I’m unable to absorb much from your example, but anyway…
You’re probably familiar with how a database sorts across multiple columns. If I said order by
firstname, lastname, phoneit would compare the firstnames, and only if theres a tie, would it then compare the last names, and again if there’s a tie, then it would compare the phone numbers.Once sorted, you pick the top N entries and display.
You can do custom sorting like this in php code too. For example, you would want to order by
num occurances in a list, tone, bowing style, etc...Thats the gist of it. I would store it in a database merely because its data and for the most part, its a great place to keep it. Plenty of import export and other data management, viewing, editing and other functionality freebies come with using a database.
If you need some sample code that mimics the database order by clause, I can dig some up I know I have somewhere.