Reputation: 257
I have fields in mysql database table caps that are imgpath
and imgname
. My image path is images/man/caps/
and image name is sun-cap.png
. Now what I want to pick both of them via this query
select imgpath, imgname from caps;
Now how to concatenate them and display it in php so the output be might like this
images/man/caps/sun.cap.png
Upvotes: 1
Views: 7291
Reputation: 5798
If you are getting the concatenated string from MySQL itself like stated by @xdazz then simply echo it like
echo $row['img'];
else if you are using query like select imgpath, imgname from caps;
use
echo $row['imgpath'].$row['imgname'];
Upvotes: 0
Reputation: 8848
use it as
$result = mysql_query('select concat(imgpath, imgname) as img from caps');
while ($row = mysql_fetch_assoc($result)){
echo $row['img'];
}
Upvotes: 0
Reputation: 230306
Something like this:
select concat(imgpath, imgname) from caps;
Upvotes: 0