SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    trying to echo image id

    Hi guys

    trying to echo the id which is stored in $field6
    PHP Code:
    echo"<img src=image.php?id='$field6'>"
    but when the x image displays and i press properties it says that there is no id being called

    many thanks in advance for your help

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Whistler, Canada
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dnbidder2005 View Post
    Hi guys

    trying to echo the id which is stored in $field6
    PHP Code:
    echo"<img src=image.php?id='$field6'>"
    but when the x image displays and i press properties it says that there is no id being called

    many thanks in advance for your help
    Try this:
    PHP Code:
    echo "<img src=\"image.php?id={$field6}\" alt=\"\" />"
    Hope this helps.

    Cheers,
    Pepe

  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that didnt work

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Whistler, Canada
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, that should pass $field6 to your image.php file. What's in your image.php file? Did you try to
    PHP Code:
    echo $_GET['id']; 
    ? What's the value of $field6?

  5. #5
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $field6 is the id of the image

    if i write it like this

    echo "<img src=image.php?id=18>";

    then it works fine

    but I need to replace the value of 18 with field6

    how would line be written with echo $_GET['id'];

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Whistler, Canada
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alternatively, you could try
    PHP Code:
    echo '<img src="image.php?id='.$field6.'" alt="" />'
    but that shouldn't make much of a difference.
    Are you sure $field6 is set properly?
    Above the echo line, add
    PHP Code:
    $field6 '18'
    If that works then something goes wrong when assigning the value to $field6..

  7. #7
    SitePoint Enthusiast Chousho's Avatar
    Join Date
    Jun 2006
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you calling this from a database or is this a variable set earlier in the page?

    In any case, when using a variable, you have to echo/print it:

    PHP Code:
    echo "<img src=\"image.php?id=$field\" alt=\"\" />";

    // Or

    echo "<img src=\"image.php?id=".$field."\" alt=\"\" />"

  8. #8
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fixed it guys

    thanks

  9. #9
    SitePoint Enthusiast Chousho's Avatar
    Join Date
    Jun 2006
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dnbidder2005 View Post
    very strange as now the x box has disappeared
    That's why I'd get a Playstation 3, not an XBox ;D

    Try editing the alt tag to say "image 1" or something.

    Is the $field variable a string giving a location? Is it an absolute path (www.domain.com/image.jpg) or a relative one (img/blah.jpg)?


Bookmarks

Posting Permissions

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