Daily Links

Hi,

I'd like to create a script that displays a set of 2 unique links (with a description), for each day of the month.

Where the script pulls these links & descriptions from a .txt file (so I can easily update these links on a regular basis without editing the index.php file each time).

So, if one month has only 30 days, it would only display the first 60 links. If the next month has 31 days, it would display the first 62 links, and so on.

I'd like to keep security and performance in mind too.

Thanks!
xerospaceAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BogoJokerCommented:
Hi xerospace,

1. Check Current Date (Day of Month)
2. Multiple by 2
3. Use that # line and the next line in the the text file

Try something like:
<?php

// Get Current Day
$day = date('j');
$day *= 2;

// Open textfile
$fh = fopen('filename.txt', 'rb');

// Get to the correct line in file:
for ($i = 0; $i < $day ** !feof($fh); $i++)
    fgets($fh);

// Read the next two lines and print them
if (!feof($fh))
{
  print fgets($fh);
  print '<br>';
  print fgets($fh);
}
else
  print 'Error, two few lines in file or error in code';

// Close the file
fclose($fh);

?>

Try that out.  I did not test the code but I expect it should work alright.  You can test it out more specifically if you give a number for each line in the textfile so if it works you see which lines are printing:
1. Line One blah blha
2. Line Two blahlahdlak

Joe P
xerospaceAuthor Commented:
Hi Joe,

Sorry about the delayed response. I apologize.

I've been trying to get this script to work, but it keeps giving me a parse error on line 11.

Any ideas?

Thanks again!
BogoJokerCommented:
I must have pressed the wrong key, they are right next to eachother * and &

This line:
for ($i = 0; $i < $day ** !feof($fh); $i++)
Should be:
for ($i = 0; $i < $day && !feof($fh); $i++)

I'm sorry about that =)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xerospaceAuthor Commented:
Thanks! I added some extra points.
BogoJokerCommented:
Glad it worked =)
Thanks for the extra points!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.