amielopez
amielopez

Reputation: 539

Displaying an <img> tag inside a div class

I have a problem here that deals with the displaying of a photo inside a variable within a div class.

Here's my code below and help me find solutions. Thanks

if($newimage){
    $url = 'http://www.client.jaobuilders.com/uploads/profile_picture/upload_photos/$newimage';
} else {
    $url = 'http://www.client.jaobuilders.com/images/blank_photo.jpg';
}

return '
    <div class="comment">
        <div class="avatar">
            '.$link_open.'
            <img src="'.$url.'" width="50px" height="50px"/>    
            '.$link_close.'
        </div>

$newimage is a variable and the value will depend on the user who logged in. I really don't know what to do. Help me.

Upvotes: 0

Views: 383

Answers (1)

Tadeck
Tadeck

Reputation: 137320

You have a problem with quotes - some of them are lacking. Also you did not close <div> tag:

return '
    <div class="comment">
        <div class="avatar">
            '.$link_open.'
            <img src="'.$url.'" width="50px" height="50px"/>    
            '.$link_close.'
        </div>
    </div>';

I can only hope this return statement is enclosed in some kind of function or method. Or at least it is the only return statement in a file that has been properly included somewhere (like $my_divs = include('some_file.php');).

Upvotes: 2

Related Questions