Not sure what to search for when solving this puzzle. Not asking for the world... just direction unless you're feeling generous. This is going to be terribly hard to expain.
My website has dropdown menus with measurements. When selecting width x height dropdowns, it checks database for price. Currently widths and heights were specific in the DATABASE such as 24, 28, 32, 36. So I just pulled the measurements from a query loop into my list... and voila it matches and echos a price.. but..
Now I'm finding out that the measurements listed will need to be in 1" increments. So, I only have a database with specific measurements but I need the entire measurement range.
Do I really have to go into the DATABASE and manually enter the SAME price for 24", 25", 26", 27"... and SAME price for 28", 29", 30", 31", ... and do this time hundreds of products?
Or is there a SQL trick that allows me to select the minimum and maximum measurement, list them in a dropdown, then match one of those 1" increment measurements that isn't exactly what the DATABASE says... but is between (for example) 24" and 28".
Hope this isn't too confusing and THANK YOU.
Thanks to Gordon this was much easier than anticipated. I made it more complicated than it should have been.
Code that worked:
SELECT * FROM price_dimensions WHERE prodid = '".$_POST['prodid']."' AND height >= '".$_POST['heightX']."' AND width >= '".$_POST['widthX']."' ORDER BY height ASC, width ASC LIMIT 1
24x28
and28x24
, and want to sell a22x22
, which one would you pick? – Quassnoi May 23 '12 at 20:34