Insert multiple rows into mysql (items separated by comma)

前端 未结 7 665
执笔经年
执笔经年 2021-01-14 12:57

I have a small problem :) I was searching the web but didn\'t find any solutions.

I have a value like this (got it from $_GET[])

tag1, tag2, tag3, tag4

7条回答
  •  盖世英雄少女心
    2021-01-14 13:23

    Use explode() function to split the string

    $tag  = "tag1, tag2, tag3";
    $pieces = explode(", ", $tag);
    

    SQL query would be

    INSERT INTO myTable VALUES ($pieces[0],$pieces[1],$pieces[2]);
    

    Good Luck!!!

提交回复
热议问题