Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Read a file per month
Name: wearebusiness Date: November 26, 2005 at 08:33:10 Pacific OS: Apache CPU/Ram: ?
Comment:
I want to read our tips and only show one per month. I was hoping to find a script that would read a file in Jan and a differant one in Feb. That way I could right all of my tips at the beginning of the year and the page would automatically update. Does any one know of a place to get such a script?
Name: FishMonger Date: November 29, 2005 at 21:41:05 Pacific
Reply:
If the “tips” files are named properly, either by month number or name, you can easily with only a couple lines open, read, and print the current month's tips file.
#!/usr/bin/perl -w
use strict; use POSIX;
# abbreviated month name e.g. Nov my $month = strftime("%m", localtime);
# month as a decimal number #my $month = strftime("%b", localtime);
open (TIPS, $month) or die $!; while (<TIPS>) { print; } close TIPS;
Summary: Hi there PHP geniuses. I've just set up a test MySQL database and have written php pages to upload to it, read the contents of it, edit the contents of it and download files from it. All these pages a...
Summary: Hi, how can I create a hyperlink to a file not on the webserver but on the user's PC? The users of the webpage will all have access to a network drive that contains a certain file that they need to op...
Summary: Look at fopen and fread to open and read a file. <?php // get contents of a file into a string $filename = "/usr/local/something.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, f...