I have two tables, one is called "options" and the other is called "option_values". The first one contains entries such as: "size, color, shape" while the other has a "option_id" field linking it back to the "options" table and with entries like: "small, medium, red, green, square, etc..." depending on what the option was.
Now what I am trying to do is find ever possible combination for all option values. For example with three values for each option (as listed above) one possible combination could be: "small/red/square" or "medium/blue/circle".
Now the tricky part is that I don't know how many options (ex: size or color) there are... could be just one in which case it's easy but it could be up to 3 or more in which case it gets pretty tricky.
From past experience I would think it would be a loop within a loop, so the first time it finds the first set of options/values and then calls itself again to find the next option/value and it does this until it reaches the last option at which point the previous iteration continues with the next in line option/value. I dunno if that made any sense but I am having a problem writing this function (or multiple functions). If anyone has any ideas please let me know. Also what would be the best way to store these "combinations" in a database?
Thanks in advance.