Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 15th, 2007, 06:35 AM
donyas donyas is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 3 donyas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 10 m 8 sec
Reputation Power: 0
Script to add entire year in table

Hi,

Im in need of a script that would insert all the dates from 2007 into a dates table. the way the table is set out is like this:

LOGDATE YEAR NO WEEK NO DAYNo
01/01/2007 2007 1 1

the table is called tblDates

can anyone suggest the best way to add the entire year (without having to add it all manually!!)

Thanks!

Reply With Quote
  #2  
Old February 23rd, 2007, 04:37 PM
Arty Ziff's Avatar
Arty Ziff Arty Ziff is offline
Fresh Squeezed Orange Juice
Click here for more information.
 
Join Date: Apr 2005
Posts: 3,999 Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level)Arty Ziff User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 2 Days 2 h 23 m 27 sec
Reputation Power: 1211
You should ask this in the MySQL forum (if that's the DB you're using), or the PHP forum (if that's the scripting language you're using. It's a trivial PHP problem. But I don't know, maybe it can be done with a query as well.

Reply With Quote
  #3  
Old February 25th, 2007, 08:13 AM
Axweildr's Avatar
Axweildr Axweildr is offline
CPAN medic ...
Dev Shed God 13th Plane (11000 - 11499 posts)
 
Join Date: Mar 2003
Location: Location: Location:
Posts: 11,401 Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)  Folding Points: 124777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 124777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 124777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 124777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 124777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 124777 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Days 2 h 24 m 22 sec
Reputation Power: 2784
Send a message via Google Talk to Axweildr
Orkut
to which field? Log date or year?
the date functions differ from database to database, so there's no point in elaborating ...
__________________
--Ax
without exception, there is no rule ...
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


09 F9 11 02
9D 74 E3 5B
D8 41 56 C5
63 56 88 C0
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
-- Jamie Zawinski
Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...

Reply With Quote
  #4  
Old October 2nd, 2007, 03:20 PM
gazever gazever is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 2 gazever User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 13 sec
Reputation Power: 0
Code:
<?php 
/// log it as a date in mysql, not day, month, year

/// 365 is number of days - this could be 1825 for 3 years if you want
/// it will automatically calculate the month and year just from incremeting the number of days

for ( $counter = 0; $counter >= 365; $counter += 1) {
$toinsert = mktime(0,0,0,date("m"),date("d")+$counter,date("Y"));
$value = "WHATEVER VALUE YOU WANT HERE";
$sql = "INSERT into tablename VALUES('".date("Y-n-j", $toinsert)."', '".$value."');";
@mysql_query($sql);
}
?>


p.s. code untested, as modified it on here from one of my scripts

Forgot to mention you will need your dbconnection password and select db info above this. or simply:

Replace:
Code:
@mysql_query($sql);

With:
Code:
echo $sql;


and copy and paste it from your browser and paste it into phpmyadmin as a sql command

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Script to add entire year in table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway