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! Link to comment https://forums.phpfreaks.com/topic/275983-extracting-date-from-mysql-db-into-three-variables/ Share on other sites More sharing options...
ade2901 Posted March 21, 2013 Author 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'] ) ); 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
Archived
This topic is now archived and is closed to further replies.