View Full Version : Adding Alt Text???

11-26-2006, 03:04 PM

I use C Panel for my mySql database and have currently got 4 fields that i use.

Wallpaper ID
Wallpaper name
Large Image
Small Image

Id like to add some alt text to be used for both sizes of images, how do i go about doing this?

Many thanks in advance

Pete Potter

11-26-2006, 04:11 PM
can you clarify? do you mean you want to add another column? or do you mean you want something to show up in the small image and large image columns if you don't insert something (i.e. a default value would be inserted)?

11-27-2006, 12:36 PM
Sorry for the delay in my response, and many thanks for your reply.

I tell a lie, i do have alt text. I believe that the Wallpaper name is what is being used for this, but i would like to extend this. So for example leave the walllpaper ID as it is but use a different description for the alt text which could improve my SEO position.

So go to this link. http://www.freepspwallpapers.co.uk/viewcategory.php?cid=12 The first image is Shawn Michaels and if you hover over the image the alt text shows Shawn Michaels. How could i change this to

FREE PSP Wallpapers - Shawn Michaels??

Please reply if you need any more info.


11-27-2006, 01:09 PM
in that case, it's absolutely nothing to do with mysql, but whichever programming language you're using to display the data, i.e. php in your case.
You will have something that looks a bit like:

$query='SELECT smallimage, wallpapername FROM images';
$rs=mysql_query($query) or die(mysql_error().$query);
while($row=mysql_fetch_array($rs) {
//this is the line to change:
echo '<img src="'.$row['smallimage'].'" alt="'.$row['wallpapername'].'" />';

simply put whatever text you want to prepend between the " and the ' after 'alt='

This is just a guess at what your code looks like. If it doesn't, then you're going to need to show us...

11-27-2006, 05:13 PM
This is what i have as a basic query?

$sql = 'SELECT * FROM `wallpapers` order by wallpaperid desc';
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo '<img src="'.$row['wallpaperimage'].'><br/>';

does this make any sence? Can you show me how i would amend this to show the following on all images;

FREE PSP Wallpapers - "Image Name"


11-27-2006, 05:22 PM
I don't think the leap from what I posted from what you have is really that great...how about giving it a try yourself?

11-27-2006, 05:35 PM
Sorry GJay, i do not understand what you mean?

11-27-2006, 07:23 PM
GJay means you have not edited this line:

echo '<img src="'.$row['smallimage'].'" alt="'.$row['wallpapername'].'" />';
correctly for what you are trying to do. You've dropped information from it instead of adding to it.

11-27-2006, 10:05 PM
Thanks. This is what i have changed to, but it does not seem to have worked?

$sql = 'SELECT * FROM `wallpapers` order by wallpaperid desc';
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo '<img src="'.$row['wallpaperimage'].'" alt="Free PSP Wallpapers - '.$row['wallpapername'].'" />';
Have i done this wrong?

11-28-2006, 12:22 AM
You have left off some quotes, alter this:

echo '<img src="'.$row['smallimage'].'" alt=fudgepops"'.$row['wallpapername'].'" />';

11-29-2006, 08:33 PM
Still not working. I will try and have another go myself, and see if i can get a friend to look at it. Thanks for help so far or any more help that can be offered.

Lee Stevens
11-30-2006, 03:23 AM
GJay has done it correct just take his code, and put in "Free PSP Wallpapers -".......

11-30-2006, 07:10 AM
if you hover over the image the alt text shows

ALTernative text displays in place of the image when the browser is set to not display images. It has nothing whatever to do with what displays when you hover over any element on a web page. The TITLE text will display when the mouse moves over any element in the page that has a TITLE.

There is one browser that has a BUG where if an image has ALT text and no TITLE that the ALT text is incorrectly displayed instead. To fix this make sure that your IMG tags always contain a TITLE even if the TITLE is blank.

12-01-2006, 03:01 PM
So my only way arounf this is to go into every title and make it say -

Free PSP Wallpapers - "Image Title" There is no way i can do the following.

If you go to the homepage of the site - www.freepspwallpapers.co.uk and click on a section such as football You are now presented with 9 football images and a title over the image.

If you hover your mouse over the image this simply shows the same text as the title of the image.

What i want is for the text when you hover over to show the "FREE PSP Wallpapers - " before the image title. And i believe this would need to be a bit of code to auto do this??