ade2901 Posted March 21, 2013 Share Posted March 21, 2013 Hi, I wonder if someone can help me... I am trying to extract the date into three different variables ready to go into three option boxes for the user to update a person's date of birth. I am using the following to split up the day, month and year: $queryDate = mysql_query("SELECT YEAR(playerDOB), MONTH(playerDOB), DAY(playerDOB) FROM player WHERE playerID='$playerID'") or die (mysql_error()); Now I have tried this within the database and can see that it splits it up. The problem I am having is being able to access them in variables. How do I go about accessing the year, day and month separately from the $queryDate variable? Appreciate the help in advance! Quote Link to comment https://forums.phpfreaks.com/topic/275983-extracting-date-from-mysql-db-into-three-variables/ Share on other sites More sharing options...
Solution ade2901 Posted March 21, 2013 Author Solution Share Posted March 21, 2013 Solved using a different method I decided to try... Here is the solution: $query = mysql_query("SELECT * FROM tableName WHERE ID='$ID'")or die(mysql_error()); $row = mysql_fetch_array($query); /*Player DOB Exploding*/ $year = date('Y', strtotime( $row['dateColumn'] ) ); $month = date('m', strtotime( $row['dateColumn'] ) ); $day = date('d', strtotime( $row['dateColumn'] ) ); Quote Link to comment https://forums.phpfreaks.com/topic/275983-extracting-date-from-mysql-db-into-three-variables/#findComment-1420166 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.