View Full Version : random link generator
lostreality
21-12-2005, 07:44 AM
php script required for random link geneation with the ability to have thumbnail pictures.
any help appreciated.
Spingo
03-01-2006, 09:46 AM
Look at this post: http://forum.zgeek.com/showpost.php?p=692534&postcount=4
You should be able to work with that code without too many dramas.
pinchy
03-01-2006, 10:39 AM
If you just want to pic from a dozen or so links, here's a quick one which uses arrays to store the link data (rather than a database)
<?php
/**************************************
quick'n'easy random link generator
**************************************/
// you can make these arrays as long as you want, just make sure there
// is a pic for each link (10 links requires 10 pics)
$listOfLinks = array('http://www.zgeek.com/1', 'http://www.zgeek.com/2', 'http://www.zgeek.com/3', 'http://www.zgeek.com/4');
$listOfPics = array('imgsrc1.jpg', 'imgsrc2.jpg', 'imgsrc3.jpg', 'imgsrc4.jpg');
// pic a random integer between 0 and the size of the lists above
$randPointer = rand(0, min(sizeof($listOfLinks), sizeof($listOfPics)));
?>
<html>
<head>
<title>Random Link</title>
</head>
<body>
<h1>Random link</h1>
<a href="<?=$listOfLinks[$randPointer];?>"><img src="<?=$listOfPics[$randPointer];?>"></a>
</body>
</html>
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.