I am a total novice and PHP is my first language, so please, no flame-mail ;-)
I have setup a very simple MySQL db with a student's name ($name), date of birth ($dob) and graduation date ($grad).
1. I want to calculate the age of the student when a client requests the page, taking the date the page was requested
and the date of birth of the student. It does explain how to do it in the MySQL documentation, but I do not know how to
pass that through PHP to the DB. I think "Select dob (TO_DAYS(NOW())-TO_DAYS($dob))/365 from STUDENTS" would
be the correct query in SQL, but how do I pass that to the DB? I also need to truncate the output to an integer.
Can someone help me with this please?
2. I cannot figure out how to format the date for display in "popular" format. I want to take $grad, which is in the format
YYYY-MM-DD in the MySQL db, and output it in the form DD Month, YYYY, e.g. 8 March, 2000. I have found a round-about
way of doing this in this forum using regular expressions, but I am certain I just don't understand how to use the "date()
and mktime()" functions.
Your help is greatly appreciated.