You should create two tables. One for Smoking habits.
Some sample values
===================
2 Non-Smoker
4 Occasional Smoker
8 Smokes Regularly
16 Trying to quit
As for dates there are many ways of doing this. If you want to write good code and account for things like leap year. You need a table that has one row for every day for a time range. Say for example 1980 - 2020. Then only populate it with valid dates. There should be no Feb 30 of any year but there should be a leap year when appropriate. Problem here is you also need to put in logic in the php as well as the database unless you want to make multiple hits to get the date. For example, select year and month, then possible dates for that month are populated. Another way is to allow the user to select feb 30, then validate against the database to see if its a valid date or not. Rejecting the value if its not appropriate. I prefer to do both simultaneous. Write a java script function that creates the possible values based on the year/month selected. You can't do this with PHP accurately without multiple hits against the web server. Then I validate that yeat again against the database.
Hope this helps
|