开发者

Split a comma separated string into multiple columns into db - php

I need some help to insert comma separates strings in开发者_如何学Pythonto multiple columns into db.

My $_POST['search'] value output. [search] => schools,books,mobile

How do i make an foreach or for to insert those data into db? :S


You can use the explode function.

$queries=explode(',', $_POST['search']

Now $query is an array containing the separated values. Then you do your query, but without further informations about that, I have to stop here.


                    $post = $_POST['search'];
                $queries = explode( ',', $post );
                foreach( $queries as $query ) {
                    $db->Execute("INSERT INTO tags SET name = '".$query."'");
                }

This seems to worked for me..

I was using @klez's informations

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜