Hi there,
I have this script:
PHP:
now I need to use this script but only show 1 event and that event has to be the one nearest the current date (ie todays date 19/07/204 and the closest event would be nearest this date)
The script works by calling flat text files with the .txt stripped away. The file names are the dates of the events. So an event for today (4th August 2004) would be named 20040804
Someone did give me this:
and although it does show just the one date it shows the wrong one. It shows tha entry last posted as against the entry clostest to todays date.
Can anyone help?
Thanks
Karl
I have this script:
PHP:
Code:
<?php
$date = date("Ymd", time()+3600*7);
$NumEvents = 0;
$handle = opendir('../event_dates');
$inc_files = array();
while (($file = readdir($handle)) !== false) {
if ($file >= $date) {
$inc_files[] = $file;
}
}
$NumEvents = count($inc_files);
if ($NumEvents > 0) {
sort($inc_files);
for ($i = 0; $i < $NumEvents; $i++) {
include '../event_dates/' . $inc_files[$i];
}
echo $NumEvents . " events are scheduled";
}
else {
echo "<strong class='red'>Sorry, no events are planned at present</strong>";
}
if($NumEvents > 2){
$html = "<p><a href='#' onclick='java script:ScrollWin.scroll('0'); return false;'>Back to top</a></p>";
}
echo $html;
?>
now I need to use this script but only show 1 event and that event has to be the one nearest the current date (ie todays date 19/07/204 and the closest event would be nearest this date)
The script works by calling flat text files with the .txt stripped away. The file names are the dates of the events. So an event for today (4th August 2004) would be named 20040804
Someone did give me this:
Code:
<?php
$date = date("Ymd", time()+3600*7);
$NumEvents = 0;
$handle = opendir('../event_dates');
$i=1;
while (($file = readdir($handle)) !== false) {
if($i==1)
{
$hfile = $file;
$i++;
}
else if ($hfile<=$file) {
$hfile = $file;
}
}
if($i!=1)
include '../event_dates/' . $hfile;
else {
echo "<strong class='red'>Sorry, no events are planned at present</strong>";
}
?>
Can anyone help?
Thanks
Karl
Comment