Forum Moderators: coopster

Message Too Old, No Replies

PHP Daily updated links lists?

linklists

         

Par5Golf

4:38 am on Mar 20, 2003 (gmt 0)

10+ Year Member



Hello
I have been looking for a php script to place randome links on a page on a daily basics.. from a tex file...but i can only fond this....and this is
the only one i can get to work is this one......

<?php

// Necessary Variables:

$RANDOM_TXT_FILE = "sample_data.txt";

// End Necessary Variables section

srand((double)microtime()*1000000);

if (file_exists($RANDOM_TXT_FILE)) {
$arry_txt = preg_split("/--NEXT--/", join('', file($RANDOM_TXT_FILE)));
echo $arry_txt[rand(0, sizeof($arry_txt) -1)];
} else {
echo "Error: can't open $RANDOM_IMG_FILE file";
}

?>


and this is the text file....

1:Line 1<BR>
1:Line 2<BR>
1:Line 3<BR>
--NEXT--
2:Line 1<BR>
2:Line 2<BR>
2:Line 3<BR>
--NEXT--
3:Line 1<BR>
3:Line 2<BR>
3:Line 3<BR>
--NEXT--
4:Line 1<BR>
4:Line 2<BR>
4:Line 3<BR>
--NEXT--
5:Line 1<BR>
5:Line 2<BR>
5:Line 3<BR>
--NEXT--
6:Line 1<BR>
6:Line 2<BR>
6:Line 3<BR>

so if i can make this work so it grabs random links on a daily basics from a text file.....i will be happy and never have a worry in my mind ever....lol

Thanks

Eric

jatar_k

4:44 pm on Mar 20, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



so what exactly is it that doesn't work? Are there error messages or it doesn't open the file?

Receptional Andy

4:48 pm on Mar 20, 2003 (gmt 0)



Try this:

<?php
$textfile ="random.txt"; // change to the filename/path of your file

$items = file("$textfile");
$item = rand(0, sizeof($items)-1);
echo $items[$item];
?>

You would need to include the href tag in the text file, or enclose the above code in href tags for the text to be a link. The random.txt file should be your links on a separate line for each.

Par5Golf

1:53 am on Mar 21, 2003 (gmt 0)

10+ Year Member



What i want is for the code i put in the message....but make it update daily.....not on every refreash....thats all....thanks

Eric