How can I revise this - Display MySQL query inside image.

Discussion in 'PHP' started by wvccboy, Oct 1, 2007.

  1. #1
    I know this doesn't make sense here:

    Print "<img src=" ".$info['Picture'] ." " width="140"><br>";

    I'm trying to Print from MySQL an image url. I get a blank page.

    How can I revise it so that I will be able to do this?

    I'll have a form so people can submit the URL, and I want it do display with all the other information (text).

    One more thing. I plan to have a login system, based on MySQL. Each user will have a unique ID. When they log in, they need to have a profile and edit it. How can I set up the PHP/MySQL so that when the user logs in, it will read the unique ID for the user?

    Thanks
     
    wvccboy, Oct 1, 2007 IP
  2. subnet_rx

    subnet_rx Well-Known Member

    Messages:
    141
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    138
    #2
    You should use:
    <img src="<?php echo $info['Picture']; ?>" width="140"><br>

    You can use that inside your HTML as long as the page has a php extension and your php gets the data for that variable before it gets to that line.
     
    subnet_rx, Oct 1, 2007 IP
    wvccboy likes this.
  3. theOtherOne

    theOtherOne Well-Known Member

    Messages:
    112
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Or if you want to stay with print...
    Print "<img src='".$info['Picture'] ."' width='140'><br>";
    PHP:
     
    theOtherOne, Oct 2, 2007 IP
    wvccboy likes this.
  4. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    or other:
    1. echo "<img src='$info[Picture]' width='140'><br />";
    2. printf("<img src='%s' width='140' ><br />",$info['Picture']);
    or without quotes
    echo "<img src=$info[Picture] width=140><br />"
     
    intoex, Oct 2, 2007 IP
  5. wvccboy

    wvccboy Notable Member

    Messages:
    2,632
    Likes Received:
    81
    Best Answers:
    1
    Trophy Points:
    250
    #5
    Ahh got it. Works now!

    Thanks guys.

    Also in regards to my other question I am awaiting an answer.
     
    wvccboy, Oct 2, 2007 IP
  6. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Store user ID (which is unique) in session, and play with it
     
    intoex, Oct 2, 2007 IP
  7. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    since html use " instead of ' the code should be

    Print "<img src=\"".$info['Picture'] ."\" width=\"140\"><br>";
    PHP:
     
    kendo1979, Oct 2, 2007 IP
  8. theOtherOne

    theOtherOne Well-Known Member

    Messages:
    112
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #8
    It is another possibility. But you don't have to do so, because HTML accepts both kinds of quotes ;)
     
    theOtherOne, Oct 3, 2007 IP