By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,729 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,729 IT Pros & Developers. It's quick & easy.

Event csv list and pulling by date...

P: n/a
Just started "playing" with php and have a question. I currently have a csv
list such as this:

11-08-03 | Tournament | Chapman rules
12-18-03 | Beat The Pro | pick your partner
etc.

Is there a way by using the first field to pull one or all the events later
than the current date and, if so, returning a date say of Nov 8 and Dec 18?

Though I wanted to give the above a go, I figured out a way to pull the
correct events if I set the first field to 20031108, etc. Here is what I
got:

$readfile = file("events.txt");

for ($k=0; $k<=count($readfile)-1; $k++) {
$fields = split("|",$readfile[$k]);

$date = date("Ymd");

if ($fields[0] >= $date) {

print ("<tr><td>$fields[1]</td><td><a class=\"noUL\"
href=\"javascript:void(0);\"
onclick=\"window.open('$fields[0].htm','NextEvent','scrollbars=yes,resizable
=yes,height=600,width=650')\">$fields[2]</a></td><td>$fields[3]</td><td>$fie
lds[4]</td></tr>");

}
}

?>

The csv file for above would be
20031108 | Nov 8 | Chapman (Pinehurst)
but there has to be a better way. Thanks for any help

Bill
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"The Biscuit Eater" <Bo*****************@comcast.net> wrote in message news:<OMJnb.42045$ao4.99863@attbi_s51>...
Just started "playing" with php and have a question. I currently have a csv
list such as this:

11-08-03 | Tournament | Chapman rules
12-18-03 | Beat The Pro | pick your partner
etc.

Is there a way by using the first field to pull one or all the events later
than the current date and, if so, returning a date say of Nov 8 and Dec 18?


I'm curious to know the purpose. BTW, you can use fgetcsv
http://in.php.net/fgetcsv

If the dates are in ISO format, you can simple compare as strings.
ie, "2002-01-30" < "2003-12-30"

If you're searching for flat file DB, Google "TextDB"

---
"Our songs have meaning for everyone. I don't know of anyone who
isn't either in love, just out of love, or else wants to be in
love."--- Graham Russell, Air Supply
Email: rrjanbiah-at-Y!com
Jul 17 '05 #2

P: n/a

"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> wrote in message
news:ab**************************@posting.google.c om...
I'm curious to know the purpose. BTW, you can use fgetcsv
http://in.php.net/fgetcsv


Two things - listing the next golfing event on a web page and have a link to
all events after the current date. It is my first attempt writing in php so
the best I could do was to set $date = date(ymd) and then compare it to the
first field of a text file similar to:

20031108;Nov 8th;Beat the Pro

if fields[0] >= $date then display fields[1] and fields[2] with a link to
another file (say 20031108.htm) containing more information. The idea of
course is not to have to change the event each month since I know all the
dates for the next year.

This is what I came up with:
http://www.billhayes.us/mgagcai/indexReal.shtml

I saw the explode command and thought I could figure out a way to do the
same thing if I had something in the file like:

11-08-03;CHAPMAN (Pinehurst);pick partner;8:30 AM Shotgun
12-13-03;Beat the Pro;Individual play;tee choice;8:30 AM Shotgun
01-10-04;Twister;(Scramble-Stableford);Four man teams (white tees)

So ultimately I want to treat the first field as a date, compare it to the
current date and display the first or all records after today's date (and
display the month and day, like Nov 8)

Bill
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.