Jump to content

Exploding from a flat-file db


smallflower

Recommended Posts

I'm having issues exploding the info into this calendar code from a flat-file db. The calendar is supposed to highlight days that are noted in the db, which is listed out below:

"12","7","2006","#dec0706","linked-day","../images/mobile.gif"
"12","8","2006","#dec0806","linked-day","../images/audio.gif"
"12","11","2006","#dec1106","linked-day","../images/email.gif"
"12","12","2006","#dec1206","linked-day","../images/mobile.gif","../images/audio.gif"
"12","13","2006","#dec1306","linked-day"


"1","19","2007","#jan1907","linked-day"

[attachment deleted by admin]
Link to comment
https://forums.phpfreaks.com/topic/33291-exploding-from-a-flat-file-db/
Share on other sites

That's the thing, nothing is happening. As you can see from the php code (the attached file) the days where something is happening, an event, that day is supposed to be highlighted blue and link to the HTML quick links below the calendar. I'm sure I'm just doing something wrong in exploding the data from the db into the php code from lines 98-109.
I'd like to point out...

[code]function generate_calendar($year, $month, $days = array(),
$day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
$first_of_month = gmmktime(0,0,0,$month,1,$year);
$day_names = array();[/code]

Odd phrasing of a function... it kinda looks like it started good till $days then the rest could just be in the function if your not going to set them..

Also... It loads stuff here

[code]//flat file db code
$fp = fopen('archives-dates.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.'; exit;}
while (!feof($fp)) {
$days = fgets($fp, 1024); //use 2048 if very long lines
list ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8) = trim(split ('\|', $line), "\"");
}[/code]

But it does nothing with it.

Another fact, $day is constantly over written.

list ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8) = trim(split ('\|', $line), "\""); is unused...


Heres a cleaner more organized $days fetching function...

[code]//flat file db code
$fp = fopen('archives-dates.txt','r');
if ($fp) {
$i=0;
while (!feof($fp)) {
$line = fgets($fp, 1024);
$days[$i] = explode(",", $line); //use 2048 if very long lines
$i++;
}
fclose($fp);
}[/code]

It displays like this.

[code]Array
(
    [0] => Array
        (
            [0] => "12"
            [1] => "7"
            [2] => "2006"
            [3] => "#dec0706"
            [4] => "linked-day"
            [5] => "../images/mobile.gif"

        )

    [1] => Array
        (
            [0] => "12"
            [1] => "8"
            [2] => "2006"
            [3] => "#dec0806"
            [4] => "linked-day"
            [5] => "../images/audio.gif"

        )

    [2] => Array
        (
            [0] => "12"
            [1] => "11"
            [2] => "2006"
            [3] => "#dec1106"
            [4] => "linked-day"
            [5] => "../images/email.gif"

        )

    [3] => Array
        (
            [0] => "12"
            [1] => "12"
            [2] => "2006"
            [3] => "#dec1206"
            [4] => "linked-day"
            [5] => "../images/mobile.gif"
            [6] => "../images/audio.gif"

        )

    [4] => Array
        (
            [0] => "12"
            [1] => "13"
            [2] => "2006"
            [3] => "#dec1306"
            [4] => "linked-day"

        )

    [5] => Array
        (
            [0] => "1"
            [1] => "19"
            [2] => "2007"
            [3] => "#jan1907"
            [4] => "linked-day"
        )

)[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.