Jump to content

php - create array help


flemingmike

Recommended Posts

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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.