Home  >  Article  >  Backend Development  >  php如何将查询到的多条数据拼接成一个文本变量?

php如何将查询到的多条数据拼接成一个文本变量?

WBOY
WBOYOriginal
2016-06-23 13:30:561238browse

如我通过一个sql一句查到3条数据,我现在想把这三条数据分行拼接成一个文本,然后赋值个一个变量,通过输出这个变量得到拼接好的文本,该如何做?


回复讨论(解决方案)

$res = '';while($row = mysql_fetch_assoc($rs)) {  $res .= $row['字段'];}echo $res;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn