How to call a name in a database with php ?

Discussion in 'PHP' started by Amilo, Mar 29, 2006.

  1. #1
    I have a site that shows car pictures pulled from a database with the following columns:

    id carname category date imagename popularity

    200 mustang transport car01 402


    When the image is reqested it shows the file as car01.
    What i wont to do is use the carname in the alt tag.

    the source code shows:
    [i mg]http://mysite.com/s/images/car01.gif[/i mg]"><br><input onClick='highlight(this);' type="text" alt=""

    Could someone tell me how to call the carname to use it in the alt tag.
     
    Amilo, Mar 29, 2006 IP
  2. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #2
    It would be best to see the code that creates the link.

    But the short of it is the name is likely in $result[carname] or whatever variable name they used.
     
    noppid, Mar 29, 2006 IP
  3. Amilo

    Amilo Peon

    Messages:
    624
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your help.

    does this look right ?

    alt=\"$result[carname]"
     
    Amilo, Mar 29, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Maybe, it depends on how the results are called.

    Post the code that generates the link and we can see. Otherwise try it and see if it works.:)
     
    mad4, Mar 29, 2006 IP
  5. Amilo

    Amilo Peon

    Messages:
    624
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This is the line of code:
    It allows users to copy the code to add to there website.

    $images=$images . "<tr><td width=\"34%\" align=\"center\" height=\"0\"><br><img src=\"images/" . $row[imagename] . "\" border=\"0\"><br><font style=\"font-size: 3pt\"> </font><br><input onClick='highlight(this);' type=\"text\" alt=\"" . $i . "\" size=\"20\" value=\"[img]http://" . $domainname . "/s/" . $row[imagename] . "[/img]\"><br><input onClick='highlight(this);' type=\"text\" alt=\"$imagename" . $i . "\" size=\"20\" value=\"&lt;img src=&quot;http://" . $domainname . "/s/" . $row[imagename] . "&quot;/&gt;\"><br><input onClick='highlight(this);' type=\"text\" alt=\"" . $i . "\" size=\"20\" value=\"http://" . $domainname . "/s/" . $row[imagename] . "\"></td>";
    Code (markup):
     
    Amilo, Mar 29, 2006 IP
  6. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #6
    $row[carname] should be where it is.
     
    noppid, Mar 29, 2006 IP
  7. Amilo

    Amilo Peon

    Messages:
    624
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #7
    type=\"text\" alt=\"$row[carname]"

    Is that the right syntax like that ?
     
    Amilo, Mar 29, 2006 IP
  8. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #8
    I'm thinking type=\"text\" alt=\"$row[carname]\"

    But I can't copy the entire string to format it for some reason to show an example or test.
     
    noppid, Mar 29, 2006 IP
    T0PS3O likes this.
  9. Amilo

    Amilo Peon

    Messages:
    624
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #9
    type=\"text\" alt=\"$row[carname]"

    Worked great !

    Thank you for spending the time helping me.

    I had a go at it for about 5 hours and even got my php book out,but theres nothing like skilled help ;)
     
    Amilo, Mar 29, 2006 IP