Home > Backend Development > PHP Tutorial > 跪求 php将多条数据写下一个字段的方法

跪求 php将多条数据写下一个字段的方法

WBOY
Release: 2016-06-13 12:25:48
Original
1039 people have browsed it

跪求 php将多条数据写入一个字段的方法

<br />多图片上传处理完成,得到图片地址数组:<br /><br />for ($i = 1; $i <= 20; $i++) {<br />	if($img[$i] != ""){<br />		echo "$img[$i] <br>";<br />	}<br />}<br /><br />这样能输出:<br />file/1.jpg<br />file/2.gif<br />file/3.png<br />file/4.gif<br />file/5.jpg<br />...........<br /><br />由于图片太多,想存入一个字段里,然后每个图片地址前加个 # 号 便于以后读取和修改,效果如:<br />file/1.jpg # file/2.gif # file/3.png # file/4.gif # file/5.jpg<br /><br />跪求下 怎么做才能存入一个img字段?<br /><br />在for里面加上 $data['img'] = '# '.$img[$i].'';<br /><br />但是在外面,insert($data);写进数据库,只有最后一条数据<br /><br /><br />
Copy after login

------解决思路----------------------
$data['img'] .= '# '.$img[$i].'';
Copy after login

------解决思路----------------------
<br />$data = ""; // 放外面<br />for ($i = 1; $i <= 20; $i++) {<br />    if($img[$i] != ""){<br />        echo "$img[$i] <br>";<br />       $data .= '# '.$img[$i].''<br />    }<br />}<br />
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