Solved

Retrieving only month needed?

Posted on 2001-06-25
5
158 Views
Last Modified: 2006-11-17
I am creating an event calendar and what it to display the current month of events but I would also like to be able to click on a month name (so July for eample) and have a page generated that displays all of Julys events.

What is the best way to store the date (when entering event dates) in order to achieve this?

Also to keep in mind, once June is over, all of Junes old events must be archived.  Either into a mySQL table or into a text file.
0
Comment
Question by:treyjeff
  • 4
5 Comments
 
LVL 2

Accepted Solution

by:
higijj earned 30 total points
ID: 6225154
use MySQL!

let's say your table is as follow:

CREATE TABLE tbl_name (event_name CHAR(20), event_desc CHAR(255), date DATE)


you could select only july event with:

SELECT * FROM tbl_name WHERE MONTH(date) = 6



0
 
LVL 1

Author Comment

by:treyjeff
ID: 6225236
So inserting would be done how?  These dates are entered so they are not always NOW()
0
 
LVL 2

Expert Comment

by:higijj
ID: 6225306
well..

<?
$date = "2001-05-15"; // for may 15th

$link = mysql_connect($SQLHost, $SQLUser, $SQLPassword) OR DIE ("Unable To Connect To Database");
     mysql_select_db($SQLDatabase, $link) OR DIE("Unable To Select To Database");
     $sql="INSERT INTO tbl_name VALUES('$event_name', '$event_desc', '$date')";
     $result = mysql_query($sql);
mysql_close($link);

?>
0
 
LVL 2

Expert Comment

by:higijj
ID: 6225309
you can get the date from a form.. with 3 select (1 for day, 1 for month, 1 for year)
0
 
LVL 2

Expert Comment

by:higijj
ID: 6235767
Thanks!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question