08-24-2010, 10:12 AM
I don't have time to implement this, but I can give some tips that might help you.
The first part you'll need is a data entry form for date of birth. A web form using HTML will work fine. I point out some ways that client-side Javascript in the browser could be used for data entry validation.
For month, you could either have a drop-down list of month names, or you could just have a text box.
If you have a text box, you also need script code to validate that the entry was numeric, at least 1, and no greater than 12.
For day of month, you could have a drop-down list that automatically adjusts its length when a month is chosen. Or you could just have a text box. If you have a text box, you need script code to validate "30 days hath September..." for the numeric entry. If you have a drop-down, you need code that responds to a change of month by updating the day menu.
For year, you could have a drop-down list going back what you consider a reasonable maximum age for likely users. Or you could just have a text box. If you have a text box, you need to warn if the year of birth entered is in the future, or so far back in the past that the arithmetic could overflow.
All of this points out one huge limitation of the way software is currently made on the Web. You should be able to get a ready-made "pick a date" script that does all the validation for you, and just drag&drop it into your site. So much for the idea of "component software."
This is a huge advantage of a software framework like .Net or Java. They include components to provide a graphical interface for selecting a date, with all the validation built in. But they require that the user have a particular type of runtime library or browser plugin installed, which brings security and performance risks. All the fun of being a system administrator, brought right to your lap!
The Bring4th Dashboard/Edit Your Profile includes an optional area for a user to enter date of birth. I just checked what happens when February 31 is entered. When the Submit button is clicked, the form is redisplayed with an error message that says "The birthday you entered is invalid. Please enter a valid birthday or leave the field empty." So there is minimal validation, but not much in the way of slick data entry functionality.
Once you have a date of birth to work with, calculating today's level is easy. Just use a date math library to find how many days between today and the given birth date. Divide by 18 and take the remainder.
Now this value needs to be reported to the user. The number could be shown on a new page that is loaded once the user submits the date of birth. The cool AJAX way of doing things is to let the server update a portion of the page, without a full page load. From the user's point of view, when they enter their date, the date entry area disappears and is replaced by a cool factoid about their current "power days" level.
The more sophisticated way to report is to show a chart. This means you need some software running on the server to generate a chart. In the Windows world, the server might run Excel. The date of birth is passed in to the Excel file, which calculates power levels going back, say, 30 days, and generates the chart. In the PHP world, probably some open source chart generator would be used, for example libchart: http://naku.dohcrew.com/libchart/pages/introduction/.
At a corporate job, I worked on a website that provided statistical reports to managers. Data was retrieved from the database, and passed to the user along with a chart generation plugin. The graphics work happened on the client side. The client had tools to switch between different types of charts such as line or bar charts, to zoom in and out and so forth. Obviously something like that would be irrelevant overkill for your project.
Now, to put it all together in php I found this article with complete sample code. http://www.phpwest.com/articles/54/Basic...f_PHP.html.
I am very quick at analysis but not that speedy at coding. I guess I just prefer writing in English for people to read. Unlike computers, my human readers can often guess correctly at what I really meant to say.
The first part you'll need is a data entry form for date of birth. A web form using HTML will work fine. I point out some ways that client-side Javascript in the browser could be used for data entry validation.
For month, you could either have a drop-down list of month names, or you could just have a text box.
If you have a text box, you also need script code to validate that the entry was numeric, at least 1, and no greater than 12.
For day of month, you could have a drop-down list that automatically adjusts its length when a month is chosen. Or you could just have a text box. If you have a text box, you need script code to validate "30 days hath September..." for the numeric entry. If you have a drop-down, you need code that responds to a change of month by updating the day menu.
For year, you could have a drop-down list going back what you consider a reasonable maximum age for likely users. Or you could just have a text box. If you have a text box, you need to warn if the year of birth entered is in the future, or so far back in the past that the arithmetic could overflow.
All of this points out one huge limitation of the way software is currently made on the Web. You should be able to get a ready-made "pick a date" script that does all the validation for you, and just drag&drop it into your site. So much for the idea of "component software."
This is a huge advantage of a software framework like .Net or Java. They include components to provide a graphical interface for selecting a date, with all the validation built in. But they require that the user have a particular type of runtime library or browser plugin installed, which brings security and performance risks. All the fun of being a system administrator, brought right to your lap!

The Bring4th Dashboard/Edit Your Profile includes an optional area for a user to enter date of birth. I just checked what happens when February 31 is entered. When the Submit button is clicked, the form is redisplayed with an error message that says "The birthday you entered is invalid. Please enter a valid birthday or leave the field empty." So there is minimal validation, but not much in the way of slick data entry functionality.
Once you have a date of birth to work with, calculating today's level is easy. Just use a date math library to find how many days between today and the given birth date. Divide by 18 and take the remainder.
Now this value needs to be reported to the user. The number could be shown on a new page that is loaded once the user submits the date of birth. The cool AJAX way of doing things is to let the server update a portion of the page, without a full page load. From the user's point of view, when they enter their date, the date entry area disappears and is replaced by a cool factoid about their current "power days" level.
The more sophisticated way to report is to show a chart. This means you need some software running on the server to generate a chart. In the Windows world, the server might run Excel. The date of birth is passed in to the Excel file, which calculates power levels going back, say, 30 days, and generates the chart. In the PHP world, probably some open source chart generator would be used, for example libchart: http://naku.dohcrew.com/libchart/pages/introduction/.
At a corporate job, I worked on a website that provided statistical reports to managers. Data was retrieved from the database, and passed to the user along with a chart generation plugin. The graphics work happened on the client side. The client had tools to switch between different types of charts such as line or bar charts, to zoom in and out and so forth. Obviously something like that would be irrelevant overkill for your project.
Now, to put it all together in php I found this article with complete sample code. http://www.phpwest.com/articles/54/Basic...f_PHP.html.
I am very quick at analysis but not that speedy at coding. I guess I just prefer writing in English for people to read. Unlike computers, my human readers can often guess correctly at what I really meant to say.
