Amazon Web Services Add-Ons

Add a little spice to your AWS site.

Amazon Web Services (AWS) can add tremendous value to an affiliate website. In my intro to AWS using PHP, we learned how to setup a simple AWS site that sells travel books. By using that example as a backdrop, there are a number of ways we can liven up the AWS experience using PHP:

Star Rating Images

Want to turn that customer rating of "3.5" into a nice star image? Chris, the owner of, has a nice solution using CSS. Create two star images of equal size, one for the highlight, one for the background. The example assumes the dimension of the star images is 13 x 12:

CSS code:
z-index: 1;
background-image: url("/images/star-highlight.gif");
background-repeat: repeat-x;
height: 12px;
z-index: 0;
background-image: url("/images/star-background.gif");
background-repeat: repeat-x;
width: 65px;
height: 12px;
PHP code:
// $Rating = the product rating
$width = $Rating * 13;
echo '<div id = "starbottom"><div id = "startop" style = "width: '.$width.'px;"></div></div>';

Replace Blank Images

In cases where Amazon does not have a product image, AWS returns a blank 1 x 1 image. To show a custom "this product does not have an image" image, use the getimagesize function to check the image's size. Don't forget to create the "no image available" image.

// $ImageUrl = the product's image URL
$imgInfo = getimagesize($ImageUrl);
if(1 == $imgInfo[0]){
$ImageUrl = '/images/no-image.gif';
echo '<img src="' .$ImageUrl. '" border="0" />';