我已经看到许多关于这个问题的堆栈溢出线程,但我无法实现这一点,所以再次发表了这篇文章。我正在使用我想使用PHP在SQL中插入标签的地方。赞 [select2 jQuery pluginData, Data, Data]
我尝试做我通过谷歌学到的东西,好吧,我在这方面是专业化的,我是PHP的新手。请帮助'我如何在数据库中插入这个,其中显示两个单词之间,如上所述,我在,Like'
我的代码是
if(isset($_POST['submit'])) {
$name = "Your_Name";
$email = "Your_Email";
$stmt = $con->prepare("INSERT INTO `test` (`name`, `email`, `color_name`) VALUES (':name',':email',':color')");
foreach ($data as $row)
{
':name' = $name;
':email' = $email;
':color' = 'MYStatus'; //I want mention here Select2 Tags Data and insert in DB where [, (space)] every two words. like [Green, Red, Blue, Pink]
$stmt->execute();
}
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://shashani-humanth.github.io/Notebook-AdminPanel/js/select2/select2.css">
</head>
<body>
<form class="bs-example form-horizontal" id="formid" method="POST" onSubmit="return validate();">
<div class="form-group col-sm-6">
<div>
<input type="hidden" name="selectname[]" id="select2-tags" style="width:260px" value="brown"/>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" name="submit" class="btn btn-sm btn-default" id="submit">Save and Publish</button>
</div>
</div>
</form>
<script src="http://shashani-humanth.github.io/Notebook-AdminPanel/js/jquery.min.js"></script>
<script src="http://shashani-humanth.github.io/Notebook-AdminPanel/js/bootstrap.js"></script>
<script src="http://shashani-humanth.github.io/Notebook-AdminPanel/js/select2/select2.min.js"></script>
<script type="text/javascript" language="javascript">
if ($.fn.select2) {
$("#select2-option").select2();
$("#select2-tags").select2({
tags:["Red", "Green", "Blue", "Pink"],
tokenSeparators: [",", " "]}
);
}
</script>
</body>
</html>
holdtom