Home > Backend Development > PHP Tutorial > 输出的数组怎么写入数据库

输出的数组怎么写入数据库

WBOY
Release: 2016-06-13 12:24:26
Original
1077 people have browsed it

输出的数组如何写入数据库?
输出的数组如何写入数据库?
2个值要写入2个字段. 
 Array ( [0] => upload/2015/09/06/20150906164734000.jpg [1] => upload/2015/09/06/20150906164734001.jpg
------解决思路----------------------
1、遍历数组,每次插入一个元素
2、连接成串后插入

怎么做是根据你的需要来的,并无一定之规
你是程序的主人,而不是程序的奴隶
------解决思路----------------------

<br />foreach($arr as $v){<br />    mysql_query("insert into tbname (image_url) values ('".$v."')");<br />}<br />
Copy after login

------解决思路----------------------
0 对应 第一个 1 对应第二个 要看你是怎么设计的....
------解决思路----------------------
$sql = "insert into 表 (IMG1,IMG 2) values('$p->upload_file[0]', '$p->upload_file[1]')";
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