|
![](/images/resource/spacer.gif) |
|
[ช่วยด้วยครับ]ขอวิธีการเก็บ Array เข้า Database แบบ (xx, xx, xx) |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
36.$strSQL = "INSERT INTO tblcb (cbtest) VALUES ('".$_POST["Industry_List"]."')";
แก้เป็น
$strSQL = "INSERT INTO tblcb (cbtest) VALUES ('".implode(',', $_POST["Industry_List"])."')";
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-11-02 12:05:59 |
By :
NewbiePHP |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ฮ๊กกกกกกกกกกกกกกกกกก ขอบคุณพี่ NewbieXYZ มากๆครับ
![comparray comparray](https://www.thaicreate.com/upload/stock/20151102120941.png?v=1001)
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
<meta charset="UTF-8">
</head>
<body>
<form action="" method="post" name="form1" >
<input type="checkbox" name="Industry_List[1]" id="Industry_List" value="ชาย" />ชาย</input>
<input type="checkbox" name="Industry_List[2]" id="Industry_List" value="หญิง" />หญิง</input>
<input type="checkbox" name="Industry_List[3]" id="Industry_List" value="ไก่" />ไก่</input>
<input type="checkbox" name="Industry_List[4]" id="Industry_List" value="แมว" />แมว</input>
<input type="checkbox" name="Industry_List[5]" id="Industry_List" value="เสือ" />เสือ</input>
<button type="submit" name="btnSubmit" class="btn btn-default">ยืนยัน/ส่งข้อมูล</button>
<button type="reset" name="btnCancel" class="btn btn-cancel">ยกเลิก</button>
</form>
<?php
for($i=0;$i<count($_POST["Industry_List"]);$i++)
{
if(isset($_POST["Industry_List"][$i]) != "")
{
echo "".$_POST["Industry_List"][$i].",";
}
}
?>
<?php
if(isset($_POST['btnSubmit']))
{
$objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
$objDB = mysql_select_db("decc");
mysql_query("SET NAMES utf8", $objConnect);
$strSQL = "INSERT INTO tblcb (cbtest) VALUES ('".implode(',', $_POST["Industry_List"])."')";
$objQuery = mysql_query($strSQL);
echo"<script language=\"JavaScript\">
alert('ลงทะเบียนเสร็จเรียบร้อย!'
</script>";
}
?>
</body>
</html>
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-11-02 12:12:01 |
By :
damnern007 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 00
|