连接超链接和文本字段


Concatenate hyperlink and text fields

我有一个数据库,有两个字段-一个是文本名称,另一个是超链接-我想将它们与超链接组合成一个文本显示:

<td><?php echo $row_RegRecordset1['fed_reg_page']; ?></td>
<td><?php echo $row_RegRecordset1['fed_reg_url']; ?></td>

显示内容如下:联邦公报页面(列名/fed_reg_Page)"23923(76)",当用户单击23923(1976)时,它将链接到"fed_reg_url"字段http://www.gpo.gov/fdsys/pkg/FR-2011-08-24/pdf/2011-21454.pdf"

如何将这两个字段连接为一个字段以便在表格单元格中显示?

文本需要用作为链接的锚标记<a>包装。

<a href="the url">the text</a>

所以,这是你需要的代码

<td>
    <a href="<?php echo $row_RegRecordset1['fed_reg_url']; ?>"><?php echo $row_RegRecordset1['fed_reg_page']; ?></a>
</td>

使用CONCAT函数所以它将是

SELECT CONCAT(field1,field2) FROM table