Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

Amazon affiliate rotator (images)

Amazon is a tremendous book retailer as well as numerous other things and in this example we will show you how you can display a random book image on your page .

Have you ever seen those pages that have our favorite books then proceed to display 3 or 4 books one after another , well I personally think these look clumsy , sometimes take a while for the images to load and generally this can make a site look amatuerish. Howabout displaying a random image from a selection now this would be better .

A typical Amazon book image link looks like this , note you will have to change the mazonaffiliateID to your own .

<A HREF="http://www.amazon.com/exec/obidos/ASIN/1861003730/amazonaffiliateID"><IMG SRC="1861003730.01.TZZZZZZZ.jpg" border="0" alt="cover" hspace="3" vspace="3"></A>

Here is the script

<?php
//this is the url part of the amazon code
$urlama = array("http://www.amazon.com/exec/obidos/ASIN/1861003730/freegraphicsandt",
"http://www.amazon.com/exec/obidos/ASIN/0672319241/freegraphicsandt",
"http://www.amazon.com/exec/obidos/ASIN/076454716X/freegraphicsandt");
//here is the img code , note we have only used the actual image
$imgama = array("1861003730.01.TZZZZZZZ.jpg",
"0672319241.01.TZZZZZZZ.jpg",
"076454716X.01.TZZZZZZZ.jpg");
//generate a random number
srand((double)microtime()*1000000);
$randno = (rand()%3);
//display amazon code
echo ("<a href =$urlama[$randno]><img src = $imgama[$randno]>");
?>

And here is an example , refresh the browser to see a different image. Note : please remember and change the affiliate ID code to your own , otherwise we will get tons of sales . (WE wont mind but you probably will . ;-)