Jump to content

Recommended Posts

Hello,

I am doing work on my schools website, and I am working on integrating the calendar with the homepage upcomming events. The tech crew at my school refuses to install MySQL becasue of security issues, so I am forced to use a flat-file database which I have little experience with. I am using a calendar script called FlatCalendar, which I have customized to fit the homepage, however, when it lists the events it sorts them by key (order in which they were added) and I need to have them sorted by date. This would be fairly easy, but the script is written with seperated day, month, and year values. I also need to find a way to have the events filtered so they don't display after they are past. Any Ideas?

I have attached the scripts. The actual script is in the index.php file and the database file is in calendar\calendar.dat. The code in the index file is also below.

[code]<?php
//always returns true so all records will be returned
function returnAll($item){
         if($item)
          return true;
}

//displays record

function show_record($record){
         $eventNumber = $record["event_key"];
         $eventName = $record["event_name"];
         $eventYear = $record["event_year"];
         $eventDay = $record["event_day"];
         $eventMonth = $record["event_month"];
//I wrote this part, which translates the name of the month stored in the db into a number
if ($eventMonth == January) { $eventMonth = '01';}
if ($eventMonth == Febuary) { $eventMonth = '02';}
if ($eventMonth == March) { $eventMonth = '03';}
if ($eventMonth == April) { $eventMonth = '04';}
if ($eventMonth == May) { $eventMonth = '05';}
if ($eventMonth == June) { $eventMonth = '06';}
if ($eventMonth == July) { $eventMonth = '07';}
if ($eventMonth == August) { $eventMonth = '08';}
if ($eventMonth == September) { $eventMonth = '09';}
if ($eventMonth == October) { $eventMonth = '10';}
if ($eventMonth == November) { $eventMonth = '11';}
if ($eventMonth == December) { $eventMonth = '12';}
//This is an attemt to add the year, month, and day into a sortable format
$eventdate = $eventYear+$eventMonth+$eventDay;
//This was supposed to add the date record to the schema, but I dont think this worked
$eventdate = $record["event_date"];

         echo "<tr><td align=\"left\" valign=\"top\"><img src=\"images/homepage/OrangeBullet.jpg\" width=\"18\" height=\"19\" alt=\"bullet\" /></td>
         <td width=\"200\"><a href=\"calendar/viewEvent.php?eventNumber=$eventNumber\" class=\"viewall\" target=\"_blank\">$eventName</a></td>
         <td width=\"100\"><font class=\"viewall\">$eventMonth-$eventDay-$eventYear</font></td>";
}

// Include the FFDB library
include("calendar/ffdb.inc.php");

//open db or create new db
$db = new FFDB();
if (!$db->open("calendar/calendar"))
{
   // Define the database shema.
   $schema = array(
      array("event_key", FFDB_INT, "key"),
      array("event_name", FFDB_STRING),
      array("event_description", FFDB_STRING),
      array("event_submitted_by", FFDB_STRING),
      array("event_month", FFDB_STRING),
      array("event_day", FFDB_INT),
      array("event_year", FFDB_INT),
  array("event_date", FFDB_INT),
   );
   
}

echo "<table><tr>
<td><table>
";
$result = $db->getbyfunction("returnAll", 'event_month');



foreach($result as $item)
   show_record($item);
echo "</table></td></tr></table>
";
?>[/code]

[attachment deleted by admin]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.