MySQL Php将<h2>添加到文本中的数据库中

时间:2015-05-15 08:26:50

标签: php mysql

我试图从1列复制到另一列基本上抓住列名称并将其放在列描述中但保持在描述的顶部,到目前为止一切都很好,我只是无法做到弄清楚如何将成品放入h2,例如

name = Best banana
description = The most yellow thing ever

end result
name = Best banana
description = <h2>Best banana</h2> The most yellow thing ever

这是我目前的代码

$sql = "UPDATE product_description SET description = if(description is NULL, name, concat(name, description));";

我试过这个:

$sql = "UPDATE product_description SET description = if(description is NULL, name, concat('<h2>name</h2>', description));";

但是这个'<h2>name</h2>'会在h2中显示单词名称而不是表格中有关如何操作的提示吗?

1 个答案:

答案 0 :(得分:2)

$sql = "UPDATE product_description SET description = if(description is NULL, name, concat('<h2>', name, '</h2>', description));";