I'm creating a calendar/schedule for a client, it's kinda rough since I'm a frontend developer and complete new with php.
This is what I got: http://www.nrg-agency.com/events/
The script is real basic, and it was sorted on most far date first, which I got working now that the upcoming date is sorted on top.
My question is, how could I create that the past events automatically will go in a new div under the schedule with "Past Events"?
This is what I got in my "Functions.php" file:
<?php
function init_db(){
global $db;
$sql = "SHOW TABLES FROM $db[db]";
$result = mysql_query($sql);
$buildNow = 'yes';
while($row = mysql_fetch_row($result)){
if($row[0] == 'joe_cal_events'){
$buildNow = 'no';
}
}
if($buildNow == 'yes'){
mysql_query("
CREATE TABLE `joe_cal_events` (
`id` mediumint(8) NOT NULL auto_increment,
`start` date NOT NULL default '2014-30-04',
`end` date NOT NULL default '2020-01-01',
`title` text NOT NULL,
`url` text NOT NULL,
`description` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
") or die(mysql_error());
}
}
foreach ($dataArray as $key => $row) {
$orderByDate[$key] = strtotime($row['start']);
}
array_multisort($orderByDate, SORT_ASC, $dataArray);
array_multisort($orderByDate, SORT_ASC, $dataArray);
function prettyDate($date,$type){
list($y,$m,$d) = explode("-", $date);
if($type == 1){
return "$m/$d/$y";
}
if($type == 2){
return(date("j F Y",mktime(0,0,0,$m,$d,$y)));
}
}
?>
And this in my events.php:
<body>
";
$q = mysql_query("select * from joe_cal_events order by start asc");
while($r = mysql_fetch_array($q)){
print "
<div class='feedEkList'><li>
<div class='itemTitle'>$r[title]</div>
<div class='itemdate'>".prettyDate($r[start],2)."</div>
";
if($r[description]){
print "<div class='itemText'>$r[description]</div>";
}
print "
</li>
</div>
";
}
print "
</div>
</body>
Thanks again!