upcoming events list...

A

Anonymous

Guest
I can't figure out why this won't work... I wrote a php script that looked at a tab-delimited file with the format below:
yyyy mm dd Name of event hyperlink

The filename of the script is events.php The script parses the file and outputs all FUTURE events in the below format:
mm.dd.yyy::<a href="events.php?title=(name of event)&event=(name of the .inc file that includes the description of the event (without the .inc))">Name</a>
If there is no hyperlink column for a particular event, the <a> element does not print.

when the script is called with the $title AND $event variables, it only displays the title of the event ($title) and below that, the file "events/".$event.".inc"

I'm trying to get a message to print if there are no FUTURE events, but all i get, every time, is a list of all the future events in teh file, then the message is printed below it.
here is my script:
Code:
<?php
 $section = "events";
 $page = "index";
 $title = "Events Calendar";
 $headerImg = $section;

 include("include/includesNormal.inc");
?>

    </td>

    <td valign="top">
     <table cellpadding="0" cellspacing="0" border="0" width="500">
      <tr>
       <td valign="top"><img width="22" height="1" src="images/blank.gif"></td>
       <td valign="top" class="header">
<?php
 if ((isset($_GET["event"])) and (isset($_GET["title"])))
 {
  print urldecode($_GET["title"]);
?>
</td>
      </tr>
      <tr>
       <td valign="top"><img width="22" height="1" src="images/blank.gif"></td>
       <td valign="top" class="text">
<?php
  readfile("events/".urldecode($_GET["event"]).".inc");

  print "<br><br>"."<a href=\"events.php\" class=\"link\" onclick=\"back();\">Back to Events</a>";
 }
 else
 {

?>
Upcoming Events</td>
      </tr>
      <tr>
       <td valign="top"><img width="22" height="1" src="images/blank.gif"></td>
       <td valign="top" class="text">
<?php

 //header
 $dataFile = "events.txt";
 $fp = fopen($dataFile, "r");
 $headers = array(
                  "Year",
                  "Month",
                  "Day",
                  "Description",
                  "Short Name"
                 );

 $lines = array();
 $subLines = array();

 if (filesize($dataFile) > 0)
 {
  while (!feof($fp))
  {
   $lines[] = trim(fgets($fp, 4096));
  }
 }

 foreach ($lines as $line)
 {
  $subLines[] = explode("	", $line);
 }
 
 
 $eventCounter = 0;

 function doIt($line)
 {
  $eventCounter = $eventCounter + 1;

  if (file_exists("events/".$line[4].'.inc') == 1)
  {
   $link1 = "<a href=\"events.php?event=".urlencode($line[4])."&title=".urlencode($line[3])."\" class=\"link\">";
   $link2 = "</a>";
  }
  else
  {
   $link1 = "";
   $link2 = "";
  }

  print $line[0].".".$line[1].".".$line[2]."::$link1".$line[3]."$link2<br>\n";
 }

 foreach ($subLines as $line)
 {
  //foreach ($line as $temp)
  //{
   //$temp = addslashes($temp);
  //}

  if ($line[0] > date("Y"))
  {
   doIt($line);
  }
  else if ($line[0] == date("Y"))
  {
   if ($line[1] > date("m"))
   {
    doIt($line);
   }
   else if ($line[1] == date("m"))
   {
    if ($line[2] > date("d"))
    {
     doIt($line);
    }
    else if ($line[2] == date("d"))
    {
     doIt($line);
    }
   }
  }
 }
 
 if (($eventCounter == 0))
 {
  print "There are no upcoming events";
 }

 fclose($fp);
 }
?>
       </td>
      </tr>
     </table>
<?php
 include("include/htmlFooter.inc");
?>
 
My first suggestion is to use a database.

Secondly, are you trying to get it say "No future events" to come up when there is future events?
 
Back
Top