Hello, I'm a newb seeking help, I first posted this in the newbie section, but nobody seemed to help(so, sorry in advanced for double posting.). Anyways, I'm working on a scheduling system that uses a visual calendar. I've already got the calendar working, but I need to make a dynamic array in some sort of loop. The purpose of the array is to tell the calendar which days of the month are a clickable link. THIS array will have nothing to do with a SQL query., I will later use another array for some of the days of the month, that have events on them. I can establish the array statically, but it needs to be dynamic of each day.
Static Code:
include_once('calendar.php');
//the days I want to have a href link. if today was the 2nd, every day from 2nd - 31st of the month should be a link.
$days = array(
2=>array('schedule.php?item=day&value=2','linked-day'),
3=>array('schedule.php?item=day&value=3','linked-day'),
4=>array('schedule.php?item=day&value=4','linked-day'),
5=>array('schedule.php?item=day&value=5','linked-day'),
// etc.
)
$time = time();
setlocale(LC_TIME, 'en_US');
//generate the calendar, and pass the $days array through as an argument.
echo generate_calendar(date('Y', $time), date('n', $time), $days, 3, NULL, 0, $pn);
Dynamic Code in need of help:
include_once('calendar.php');
//how many days are in the month? in this case, 31
$lastday = mktime(0,0,0,date("m"),date("t"),date("Y"));
$lastday = strftime("%d",$lastday);
//current day the code is executed.
$day = date('j',mktime(0,0,0,date("m"),date("d"),date("Y")));
//declaring the array
$days[] = array();
//crazy mess of a loop that tries to get the job done, and I know it won't. This is where I need help.
for (;$day<=$lastday;$day++){
array_push($days[$day], array_push($day=array("schedule.php?item=day&value=[$day]", 'linked-day')));
}
$time = time();
setlocale(LC_TIME, 'en_US');
//generate the calendar, and pass the $days array through as an argument.
echo generate_calendar(date('Y', $time), date('n', $time), $days, 3, NULL, 0, $pn);
Bottom-Line Question:
How can I generate an array using a loop? or something similar?
I'm new to php and programming in general, I literally picked up a book last week, and I have the general theory of programming. I have a CMS based site (Joomla), and I plan to implement a Scheduling System and & Calendar into it, but for now, I just need some help getting those linked-days generated :o
Any help is greatly appreciated Ask me any questions necessary, and I will answer quickly. Thanks in advanced.
-Jason