<html>
<head><title>Week #4 </title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>
<body>


<?

/* Week 4 Advanced:
Write a script to rotate banners kept inside a multi-dimensional array in at 
least 3 different categories stored using a separate file and using require 
to bring into the main script which does the rotation and weighting the 
results of one banner category over the other two. */

require("arraylist.php");

/* This is the php code in "arraylist.php"
// set master array
$master_array = array('computing', 'family', 'hunting');

// Set 3 subject multidimensional array computing/family/hunting
$subject = array('computing' => array('1.gif', '2.gif', '3.gif'),
'family' => array('4.gif', '5.gif', '6.gif'),
'hunting' => array('7.gif', '8.gif', '9.gif'));*/

// set the random time seed
mt_srand(time());

// use seed, weighing the percentage to whatever favor I like (1 is lowest, 100 is highest), a percentage
$percentage mt_rand(1,100);

// percentage to equal "computing"
if ($percentage <= 30)
   {
    
$number 0;
    }
// percentage to equal "family"
   
elseif ($percentage <= 75)
   {
    
$number 1;
    }
// percentage to equal "hunting"
   
else {$number 2;}

// set the minimum STATIC value of seed and maximum random value of seed
$random_number mt_rand(0,2);

// path to images
$image_path 'images';

$todays_subject $master_array[$number];
$todays_image $subject[$todays_subject][$random_number];

//print results
print("The Random Subject is:  $todays_subject ");
print(
" <img src=\"$image_path/$todays_image\" height=100 width=100> ");
echo( 
$todays_image);

?>







<pre>
</pre>
<br>
<iframe src='wk4advsrc.php' width='850' height='300'></iframe>
<br>
<a href='../index.html'>BACK</a>
</body>
</html>