INSERT for date range


Posted on 16th Feb 2014 07:03 pm by admin

Hi all

I have the following table

Did you know?Explore Trending and Topic pages for more stories like this.
Code: [Select] `date` date
`day` int(2)
`month` int(2)
`year` int(4)
If I pass a date range in PHP, such as

Code: [Select]$datefrom = '2009-02-20';

$dateto = '2009-02-25';
How can I get it to INSERT a record for every date between that date range?

So with that example date range, it would do

Code: [Select]INSERT INTO `dates` (`date`, `day`, `month`, `year`) VALUES
('2009-02-20', '20', '02', '2009'),
('2009-02-21', '21', '02', '2009'),
('2009-02-22', '22', '02', '2009'),
('2009-02-23', '23', '02', '2009'),
('2009-02-24', '24', '02', '2009'),
('2009-02-25', '25', '02', '2009')
but not do an INSERT if any of those dates already exists in the database.

Any help would be great

Thanks
No comments posted yet

Your Answer:

Login to answer
256 Like 53 Dislike
Previous forums Next forums
Other forums

Help If user voted, block them
On my Prayer request site, i let users Click a button to Pray for somone that has posted a pray, i g

Displaying different page content, depending on the logged in user.
Hi all, I am new to ASP.net (and web development in general), and have a question about how I can di

do while conditions
i want to display 6 images in a 2x3 table
now what would be the correct logic to
count that th

From Header Showing 'Unkown' In Hotmail? Why?
Code: $to = $row_GetID['email_addr'].',sales@mywebaddress.co.uk';
$subject = 'Thank you for you

Inserting Data into a MS Access DB using PHP.
As part of my uni course I am doing a placement at a company whom want me to create a client zone fo

Error in query: Resource id #4??
hey guys, having a minor (i think) problem here that i havent been able to figure out. long story sh

pull content
I have an existing page, domain/adverts.php which has a good PR. I've just rebuilt my site and the n

getting rid of quotes in strings
sick of trying to deal with them in multiple ways (entering in and taking from database, echoing, ec

cURL and Sessions
Ohai.

So, I'm trying to cURL a bunch of things off of a page, and put them into a session. I'

very easy question about SQL info
Hello,
I think that I have a very easy question.
I know how to create a form using php SQL and

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash