Hi,
I am new to PHP. I have a PHP calendar Script on a site that I am designing that uses a MySql database. My client would like for the events that have been listed on the calendar to be seen on the Home Page of the site. For example, on the right hand side of the page there is a division already coded in the CSS. I want to list the events from the calendar page there. I am not sure what I will need to do to do this. (As I said, I am very new to PHP.) Can somebody give me somewhere to start with this?
Thanks,
Trouble
Need help with Calendar Script
I do already have the calendar working..The events do already write to the database from the calendar..... Here is the URL for the calendar.....
http://www.premierewebdesign.net/CCSI/c ... /index.php
What I am trying to do is show the events that are listed on the calendar on the home page Please see http://www.premierewebdesign.net/CCSI/index.html
On the right side of that page you will see a column that says Upcoming Events..Right now it just has some placeholder text. But that is where I would like the Events that are on the calendar to be displayed.
I assume the data is already in the database just retrieve it and show that data
I am going to assume the data in the data base has a date set to it and it is in the standard date format YY-MM-DD.
So first retrieve the date and then explode it at the "-"
list( $datamonth, $dataday, $datayear) = explode ('-', $recordsdate)
Then make a date formated so that you can find the day of the year so you don't display old events
$newdate= mktime('0','0','0',$datamonth,$dataday,$datayear)
$datadoy = date('z', $newdate);
And then check the todays day of the year against that
$today = date('z');
if($today <= $datadoy){
//display the rest of the records data
}
If all that is in a while loop or foreach loop for the table that has the data it will display the all the records that are later in the year than today.
Of course if that is alot of records you may want to do a ORDER BY and a LIMIT in your SQL query.
As well the date('z') is a hard number like 245 and if you wish to move that number in either direction just add or subtract
$today = $today - 10;
Also the biggest hangups you will have is displaying records for next year. Particullarly as you get closer to the end of the year.
One trick is to just put the year number in front of the day of the year
$today = (date('Y') . date('z'));
$datadoy = ($datayear . date('z', $newdate));
This will make sure that next years date is always > any date from this year and will dispaly it.