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
Share on other sites

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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.