Im looking for a script which i can paste into like 300 pages so when someone clicks on my "random link" picture it will look through a text document or a php document through all 300 of my pages and randomly select one line to send the visitor to when the visitor clicks the "random link" picture ... anyone know anything about this ?
this is pretty easy with PHP, ASP.NET, or any backend programming. The concept is the same in all places, though. Create an array with all your sayings (or even place them in a database) and when the user clicks the link, you have a randomization function that will go through and choose a number from your array and spit back the corresponding data. In .NET i know you need to initiate the Randomize() function, and I'm pretty sure there's something equivalent in PHP (maybe rand(0,300) in php?) HTH
create a file text called random.lst adding your pages this way: http://your_site.com/page1.htm http://your_site.com/page2.htm http://your_site.com/page3.htm .... etc. etc. Code (markup): now another file called random.php with this code: <?php $RANDOM_URL_FILE = "random.lst"; srand((double)microtime()*1000000); if (file_exists($RANDOM_URL_FILE)) { $arry = file($RANDOM_URL_FILE); for($i = 0; $i < sizeof($arry) ; $i++) { if (preg_match("/http:/", $arry[$i])) $good_arry[$j++] = chop($arry[$i]); # PHP 4.0 arry_push ($good_arry, $arry[$i]); } if ($good_arry) { header("Location: ".$good_arry[rand(0, sizeof($good_arry) -1)]); } else { echo "missing data file"; } } else { echo "error: can't open $RANDOM_URL_FILE file"; } ?> Code (markup): upload both to your root directory and call them this way: <a href="random.php">random link</A> Code (markup):
I did what you said and this happens ..... http://www.geekazoid.co.uk/random.php I think there must be an error in the script somewhere
randomizing is working but seems the problems is with your pages scripting. are Leaderboard.html, Horizontal.html, et within the Funny-Pictures directory? if not give to your pages the full url to such files, or place random.php and random.lst within this directory to correct the problem.
hey thanks for that code, I've been using java all this time and this will save me a lot of time when updating. Also is there a way to display a random image (with link). Right now I'm using a .js to do that and just run three in a row so it displays 3 diffrent images, I'm guessing a php file would make it a lot more efficient.
Definitely PHP is best than javascript and this in the way to accomplish your wish: <?php $pics = "10"; // number of images in your directory $ext = "gif"; // whatever image extension mt_srand((double)microtime()*1000000); $PicRandom = mt_rand(0,$pics); if ($PicRandom == "0") { $PicRandom = "1"; } echo "<a href=\"$PicRandom.$ext\"><img src=\"$PicRandom.$ext\" alt=\"Random Picture #$PicRandom\"></a>"; ?> Code (markup): Remarks: all images must have the same extension all images must be renamed accordingly (1.gif, 2.gif, 3.gif, etc.) if you have numerous images, save time downloading Total Commander Total Commander is an alternative to Windows Explorer, with dual panels and multi-rename tool offering different options just by pressing Ctrl+M, available at ghisler.com
Glad to hear these pieces of code are helping you. Btw, another must-have for quick image procesing is irfanview, useful when you a mix of jpg, gif, png, etc. Using its batch facility you can make them all the same format at once.