getting image to display using url in mysql

Discussion in 'PHP' started by harlequeen, Oct 26, 2006.

  1. #1
    Hi

    I have a url to an image in my database and I want to call it to a page. It is going to be a random call, but for now I've only got one in.

    I can get the url to echo to the page, but can't get the image. I have done this before, but for the life of me, I can't rmember how.

    Here is my code:
    $sql=mysql_query("SELECT myurl FROM thumbsurl ORDER BY RAND() LIMIT 1");
    
    
    while(@$row=mysql_fetch_array($sql)){
    //Build formatted result here
    
    ("<h5>");
    $myurl=$row["myurl"];
    echo $row['myurl'];
    echo "<img src=$myurl>"; 
    
    }
    PHP:
    I have been going around in circles with this and seem to be getting nowhere.
    Any help would be appreciated

    Harlequeen
     
    harlequeen, Oct 26, 2006 IP
  2. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I Haven't understood your code, But i would do it like that :

    $sql=mysql_unbuffered_query("SELECT `myurl` FROM `thumbsurl` ORDER BY RAND() LIMIT 1");
    $row = mysql_fetch_array($sql);
    echo "<img src=\"{$row['myurl']}\">";
    PHP:
    Hope it works :)
     
    Morishani, Oct 26, 2006 IP