Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    Gainsborough
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding Alt Text???

    Hi

    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
    --
    Peter Potter
    PSP Wallpapers

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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)?

  • #3
    Regular Coder
    Join Date
    Jun 2006
    Location
    Gainsborough
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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/v...ory.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.

    Peter
    --
    Peter Potter
    PSP Wallpapers

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    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:
    PHP Code:
    $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...

  • #5
    Regular Coder
    Join Date
    Jun 2006
    Location
    Gainsborough
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"

    Peter
    --
    Peter Potter
    PSP Wallpapers

  • #6
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    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?

  • #7
    Regular Coder
    Join Date
    Jun 2006
    Location
    Gainsborough
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry GJay, i do not understand what you mean?
    --
    Peter Potter
    PSP Wallpapers

  • #8
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    GJay means you have not edited this line:
    PHP Code:
    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.

  • #9
    Regular Coder
    Join Date
    Jun 2006
    Location
    Gainsborough
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    --
    Peter Potter
    PSP Wallpapers

  • #10
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    You have left off some quotes, alter this:

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

  • #11
    Regular Coder
    Join Date
    Jun 2006
    Location
    Gainsborough
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    --
    Peter Potter
    PSP Wallpapers

  • #12
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    GJay has done it correct just take his code, and put in "Free PSP Wallpapers -".......

  • #13
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,628
    Thanks
    0
    Thanked 648 Times in 638 Posts
    Quote Originally Posted by Potter_gold View Post
    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.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #14
    Regular Coder
    Join Date
    Jun 2006
    Location
    Gainsborough
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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??

    Peter
    --
    Peter Potter
    PSP Wallpapers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •