user5443928
user5443928

Reputation:

How to set image path in image tag using PHP

I need one help.I need to set the image path after fetched from DB inside image tag using PHP.I am explaining my code below.

$getcustomerobj = $dbobj->getNewsData($id);
div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-left">Upload Image :</span>
<input type="file" class="filestyle form-control" data-size="lg" name="newsimage" id="newsimage" onChange="javascript:addImage(event,'img','disImage');">

</div>
<div id="disImage" style="display:none;"> 
<div class="input-group bmargindiv1 text-right col-md-12" >
<img src="uploads/"'.<?php echo $getcustomerobj->image ?>.' name="pro" id="img" border="0" style="width:50px; height:50px; border:#808080 1px solid;" />
 </div>

Here i am getting the data from DB using $getcustomerobj but unable to display it.Please help me.

Upvotes: 0

Views: 7962

Answers (2)

noushid p
noushid p

Reputation: 1483

your code <img src="uploads/"'.<?php echo $getcustomerobj->image ?>.' name="pro" id="img" border="0" style="width:50px; height:50px; border:#808080 1px solid;" /> change to

<img src="<?php echo 'uploads/'.$getcustomerobj->image ?>" name="pro" id="img" border="0" style="width:50px; height:50px; border:#808080 1px solid;" />

Upvotes: 0

Sougata Bose
Sougata Bose

Reputation: 31739

You are doing it wrong. The path should be inside the "s. Try with -

<img src="uploads/<?php echo $getcustomerobj->image ?>" name="pro"...

would work.

Upvotes: 1

Related Questions