Location: PHPKode > projects > InvisiblePortal > trunk/menu.php
<?
echo '<div id="menu">';
echo '<div class="menu_head">NAVIGATION</div>';
echo '<ul>';
echo '<li><a href="index.php">Home</a></li>';
echo '<li><a href="index.php?page=gallery">Gallery</a></li>';
echo '<li><a href="index.php?page=faq">FAQ</a></li>';
echo '</ul>';
echo '<br />';
echo '<div class="menu_head">RANDOM IMAGES</div>';
randomThumb();
echo '<br/>';
randomThumb();
echo '</div>';

function randomThumb()
{
	$randdir = 1;
	$query = "SELECT * FROM `galconf`;";
	$result = mysql_query($query);
	if(!$result)
	{
		die('Error opening database:  '. mysql_error());
	}
	$row = mysql_fetch_array($result);
	$query2 = "SELECT * FROM `album` WHERE `id` = '".$randdir."'";
	$result2 = mysql_query($query2);
	if(!$result2)
	{
		die('Error opening database:  '. mysql_error());
	}
	$row2 = mysql_fetch_array($result2);
	$imgdir = $row['galpath'].$row2['albpath'].$row['imgpath'];
	$tndir = $row['galpath'].$row2['albpath'].$row['tnpath'];
	$random_image_dir = $imgdir;

//open, read and count dir contents 
$folder = opendir($random_image_dir);
while (false !== ($file = readdir($folder))){
if ($file != "." && $file != ".."){
$counter++;
$names[count($names)] = $file;
	}
}
closedir($folder);
sort($names); 
 

//get random file
Srand(microtime() * 1000000);
$rand_max = $counter - 1;
$Ran_image = rand(1,$rand_max);
$image = $random_image_dir.$names[$Ran_image];

$tnimage = $tndir.$names[$Ran_image];


//display image
echo "<a href=\"" . $image . "\"><img src=\"";
echo $tnimage;
echo "\" alt=\"random image\" /></a>";

};

?>
Return current item: InvisiblePortal