Image Alt Text for SEO purpose

When you paste in PHP code that is supplied by a Affiliate Manager or Merchant, there usually is not an Alt tag in the image portion of the embedded html code.The thing is, some search engines count the ALT tag text in their calculation of that page’s keyword(s) ranking.

After all, when I create non-DataFeed, every-day kind of html pages that have images, I always make sure to take advantage of using the “Alt” paramater of those images to hold a keyword phrase, so I should be able to do this here.


What I did is checked which of the PHP statements was the one responsible for displaying the Image.
Then I separated this line into two separate “echo” statements so that I could squeeze an alt=keyword after the “border=0
You don’t want all images to have the same keyword of course.

Thus the need to add a php variable: $index = 0;

I have two different keywords that I’m optimizing this page for: (these are examples, I’d be insane to try to put up a cell phone affiliate site probably)

cellphones

modern cellphones

And these two keywords would apply to any of the pictures that would show up, so I’ll just pick the first two images to set these alt text for.

PHP Code

The result is that on the page containing maybe 10 to 20 products with an image for each one, you have at least one image with an Alt Text specifying the primary keyword and at least one image specifying the secondary keyword. I don’t know if Google penalizes a page if you have two or more images with the same ALT text (for a total of four or more). I guess I like to play it safe and set just two of the 10 to 20 images to my keywords, each one to a different keyword.

Display Something On Your Page In case the Sql Query Fails

If you’ve ever seen something similar to this on a web site:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /cellphones.html on line 50,

it could mean that the webmaster didn’t include “error-handling” within the php code that queries the database.

The following is one solution:

There is usually an initial “priming” read of the database, before a loop commences.
(this should already be in your code that is supplied.) It usually looks like this:

$row = mysql_fetch_array($result);

First, put an ampersand in front of the mysql_fetch_array() function so that the error is suppressed.

Next, add the code you see below. ( the “if” condition )
The final result is:

Instead of

$row = mysql_fetch_array($result);,

you have:

$row = @mysql_fetch_array($result);
if (!$row)
{
echo “Some HTML code here, maybe, that displays a static picture and some text, or just a banner Ad”;
return;
}