I want to build a simple Size Finder for my Fashion Online Shop.
For the beginning, let's say there are 3 Input fields for Shoulder Width, Weight and Height and a checkbox for the gender. When the user enters their values, the script should automatically search for the nearest/best matching result and return it.
Let's say the user enters the following values.
Gender: male
Weight: 75kg
Height: 170cm
Shoulder Width: 56cm
The "male" table of values contains the following information.
| weight | height | shoulder | recommended size |
|---|---|---|---|
| 50 | 155 | 40 | XS |
| 65 | 165 | 45 | S |
| 75 | 175 | 50 | M |
| 85 | 185 | 55 | L |
| 95 | 195 | 60 | XL |
I'm a bit fit in PHP and JS but don't want to use a database and somehow solve that with (multidimensional?) arrays and I haven't the faintest idea how to make the script search within multiple values for the closest one, using some sort of priority system for certain thresholds. What would you recommend as the best approach here? Somehow I have the feeling that I am overlooking a logic error or at least not paying attention to something that can lead to problems later...