Focus Ifeanyi Focus Ifeanyi - 26 days ago 8
HTML Question

PHP tag not working within echoed HTML tag

I don't know why the image i not displaying, I guess it's because of the echoed variable is not done properly. Kindly assist me.

Here is the code:

<!-- User account -->

<?php if($this->session->userdata('logged_in')){

$session_data = $this->session->userdata('logged_in');
$data['username'] = $session_data['username'];
$data['email'] = $session_data['email'];
$profile_image = base_url().'assets/img/logo-berkeley.png';



echo '<div class="pull-right">

<div class="dropdown user-account">
<a class="dropdown-toggle" href="#" data-toggle="dropdown">
<img src=" . echo $profile_image;. " alt="avatar">
</a>

<ul class="dropdown-menu dropdown-menu-right">
<li><a href="user-login.html">Login</a></li>
<li><a href="user-register.html">Register</a></li>
<li><a href="user-forget-pass.html">Forget pass</a></li>
<li><a href="#">Logout</a></li>
</ul>
</div>

</div> '; } else { echo '<div class="pull-right user-login">
<a class="btn btn-sm btn-primary" href="#">Login</a> or <a href="#">register</a>
</div>'; } ?>




<!-- END User account -->

Answer

replace your this line

<img src=" . echo $profile_image;. " alt="avatar">

with below one

<img src="'.$profile_image.'" alt="avatar">