flemingmike Posted July 9, 2012 Share Posted July 9, 2012 hi, im trying to create a date array based on the results of a query. here is what i have $query = "SELECT * FROM holidays"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $holidays=$row['date']; } im trying to get this to look something like this after i exit the } $holidays=array("2012-12-25","2012-12-26","2013-01-01"); thanks! Link to comment https://forums.phpfreaks.com/topic/265442-php-create-array-help/ Share on other sites More sharing options...
Pikachu2000 Posted July 9, 2012 Share Posted July 9, 2012 $holidays[] = $row['date']; Link to comment https://forums.phpfreaks.com/topic/265442-php-create-array-help/#findComment-1360341 Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 you set the database to a var char setting then you use the date function. <?php $update_date=date("d-y-m"); ?> you update to the database. you then Paul them out with the code you provided. but you want to do what put them back as a array what? Link to comment https://forums.phpfreaks.com/topic/265442-php-create-array-help/#findComment-1360344 Share on other sites More sharing options...
flemingmike Posted July 9, 2012 Author Share Posted July 9, 2012 Thank! Link to comment https://forums.phpfreaks.com/topic/265442-php-create-array-help/#findComment-1360345 Share on other sites More sharing options...
Pikachu2000 Posted July 9, 2012 Share Posted July 9, 2012 you set the database to a var char setting then you use the date function. NO. You store dates in a DATE field, not a VARCHAR field. <?php $update_date=date("d-y-m"); ?> you update to the database. You do not store dates in that format. You store them from most-to-least significant digit, YYYY-MM-DD format, as is required by the DATE field data type. Otherwise you have to do all sorts of gymnastics to do any comparisons or math with them. you then Paul them out with the code you provided. but you want to do what put them back as a array what? Link to comment https://forums.phpfreaks.com/topic/265442-php-create-array-help/#findComment-1360347 Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 i was told if i use the date function use strtodate() and var char for database. so what can i do if i use the date database format any think interesting? how it more easy that interesting lol Link to comment https://forums.phpfreaks.com/topic/265442-php-create-array-help/#findComment-1360353 Share on other sites More sharing options...
Pikachu2000 Posted July 9, 2012 Share Posted July 9, 2012 Here are all of the MySQL date & time functions. Most of them work only with YYYY-MM-DD (or YYYY-MM-DD hh:mm:ss) format. Link to comment https://forums.phpfreaks.com/topic/265442-php-create-array-help/#findComment-1360358 Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 thank you so much your brilliant. Link to comment https://forums.phpfreaks.com/topic/265442-php-create-array-help/#findComment-1360359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.