我在imgpath
和imgname
的mysql数据库表格中有字段。我的图片路径为images/man/caps/
,图片名称为sun-cap.png
。现在我想通过这个查询选择它们
select imgpath, imgname from caps;
现在如何连接它们并在php中显示它,所以输出可能就像这样
图像/人/帽/ sun.cap.png
答案 0 :(得分:3)
select concat(imgpath, imgname) as img from caps;
答案 1 :(得分:0)
这样的事情:
select concat(imgpath, imgname) from caps;
答案 2 :(得分:0)
将其用作
$result = mysql_query('select concat(imgpath, imgname) as img from caps');
while ($row = mysql_fetch_assoc($result)){
echo $row['img'];
}
答案 3 :(得分:0)
如果你从@xdazz所说的MySQL本身获取串联字符串,那么就像回复它一样
echo $row['img'];
否则,如果您使用select imgpath, imgname from caps;
使用
echo $row['imgpath'].$row['imgname'];