Lower Left
Let's look the code for the lower left corner of the website. In HomeSite, open up the file called "lowerleft.inc.php" and look at the following code:
| <center> <?php srand((float) microtime() * 10000000); $image[1]['pic']='http://www.dgdevelco.com/ads/adbutton160x160/hostmonsterbutton.gif'; $image[1]['link']='http://www.hostmonster.com/track/dgdevelco/text1'; $image[2]['pic']='http://www.dgdevelco.com/ads/adbutton160x160/paypalbutton.gif'; $image[2]['link']='https://www.paypal.com/us/mrb/pal=BLWBD2VMK5C7J'; $image[3]['pic']='http://www.dgdevelco.com/ads/adbutton160x160/payloadzbutton.gif'; $image[3]['link']='http://www.payloadz.com/rs/go.asp?rs_id=15764'; $rn = array_rand($image); echo '<a href="' .$image[$rn][ 'link']. '">'; echo '<img src="'.$image[$rn][ 'pic']. '">'; ?> </center> |
This code is an optional php script that randomly places a different picture on the webpage each time the webpage is loaded. Each picture has an associated hyperlink so that when the image is clicked, it will take the visitor to that site.
Ok, let's look at this code in detail. The first line of code "<center>" centers the picture in the area it is placed so that it looks good with the rest of the webpage.
The next line of code tells the computer to start a php script. Anytime a php script is started, this code must be included. This tag is "<?php".
The next line "srand((float) microtime() * 10000000);" basically tells the script that the following strings will need to be randomized.
This is where it starts to get interesting. The following line defines the first image to rotate. The code "$image[1]['pic']=" defines this image as picture number one. The next portion "'http://www.dgdevelco.com/ads/adbutton160x160/hostmonsterbutton.gif'" is the absolute path to the image. The last character ";" is required at the end of every tag in php. Without it, the script will not work properly.
The next line starts with the code "$image[1]['link']=". This defines the link associated with the first image. In this case, that link is "'http://www.hostmonster.com/track/dgdevelco/text1'" And the last character is ";" to complete the tag.
The next two sets of code do exactly the same thing as the last set, except it defines image number two and image number three. This could keep going by creating new sets of code lines with different numbers to rotate through more images.
The next line of code "$rn = array_rand($image);" generates the randomization of the sets of code.
The echo lines "echo '<a href="' .$image[$rn][ 'link']. '">';" and "echo '<img src="'.$image[$rn][ 'pic']. '">';" display the random image with the associated link to the web page.
The code "?>" completes the php code.


