Home > Backend Development > PHP Tutorial > php怎么将查询到的多条数据拼接成一个文本变量

php怎么将查询到的多条数据拼接成一个文本变量

WBOY
Release: 2016-06-13 12:22:55
Original
1137 people have browsed it

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

$res = '';<br />while($row = mysql_fetch_assoc($rs)) {<br />  $res .= $row['字段'];<br />}<br />echo $res;
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template