lukkyjay Posted December 14, 2007 Share Posted December 14, 2007 I'm putting together a database of prices. The prices are based on an age range (i.e.: 35-39, 40-44, 45-49...). What would be the best way to setup the "age" column in mysql and what should the select statement look like? Quote Link to comment https://forums.phpfreaks.com/topic/81606-selecting-age-from-a-range/ Share on other sites More sharing options...
paul2463 Posted December 14, 2007 Share Posted December 14, 2007 i take it you will have 5 or 6 prices in the table base don age range? item price ageRange chair 10.50 30-35 chair 9.50 35-40 etc??? if so you can have an ageRange column which can just be a number (if there are ten age ranges then a number up to 10) and then the select statment would be $query="SELECT chairPrice FROM table WHERE ageRange = 3" //if the third age range = 35-40 hope that makes sense Quote Link to comment https://forums.phpfreaks.com/topic/81606-selecting-age-from-a-range/#findComment-414757 Share on other sites More sharing options...
lukkyjay Posted December 14, 2007 Author Share Posted December 14, 2007 Ahhh, yeah. I definitely wouldn't have thought of that. And before that I can use either an if/else statement or a switch/case statement to determine what category (number) the entered age would be... Thanks Paul! Quote Link to comment https://forums.phpfreaks.com/topic/81606-selecting-age-from-a-range/#findComment-414916 Share on other sites More sharing options...
lukkyjay Posted December 20, 2007 Author Share Posted December 20, 2007 I have the database setup. It has multiple products with multiple features that have different prices based on age and gender. A single person, husband/wife, or family can get quotes and the prices are just added together. i.e.... product A in blue is $X for a single person but product A in blue is $XY for a husband and wife or $XYZ for a husband wife and child. I'm trying to figure out what would be the best way to sum (if needed) multiple results into a repeat region and have the price field show the value for either the single person getting quotes, the person + spouse, or the person + spouse + kid(s), and so on with different possible combinations. I would be very thankful if somebody can point me in the right direction with a function name or a process I should be thinking about. Quote Link to comment https://forums.phpfreaks.com/topic/81606-selecting-age-from-a-range/#findComment-419869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.