|
 |
|
ขอแนวทางการเขียนโค้ดนำข้อมูลใน CheckBox ลงในฐานข้อมูลหน่อยครับ |
|
 |
|
|
 |
 |
|
โค้ดที่ใช้อยู่ครับ
ฟอร์มรับ

หน้าSaveครับ

|
 |
 |
 |
 |
Date :
2018-06-06 10:53:17 |
By :
community2017 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$nature = $_POST['nature'];
if ($nature != 'สภาพเรียบร้อย') {
$nature = 'ชำรุดเสียหาย';
}
$nature // เอาไป insert ลงดาต้าเบส แบบง่ายๆ
ปล.ครั้งหน้า แปะโค๊ดเอานะ สกรีนภาพมาแบบนี้หลายๆ คนเค้าขี้เกียจตอบ เพราะต้องก็อปโค๊ดเดิมมาลอง
|
 |
 |
 |
 |
Date :
2018-06-06 12:15:04 |
By :
Pong Thep |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโทษด้วยนะครับ
โค้ดด้านบนนี่เอาไปใส่ไว้ใน หน้าSaveใช่ไหมครับ
รบกวนสอนวิธีนำไปใส่ด้วยได้ไหมครับ
ขอบพระคุณครับ
|
ประวัติการแก้ไข 2018-06-06 13:43:37
 |
 |
 |
 |
Date :
2018-06-06 13:42:08 |
By :
community2017 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
//เอาไว้หน้า save ครับ
//จาก code ที่พี่เขาให้มา
$nature = $_POST['nature'];
if ($nature != 'สภาพเรียบร้อย') {
$nature = 'ชำรุดเสียหาย';
}
$nature;//เอาตัวแปรนี้ที่ได้จากการเช็คแล้วไปใส่ใน code insert
$sql = "insert into tb_chack (test) value ('$nature')";
//ประมาณนี้ละจ้า
|
ประวัติการแก้ไข 2018-06-07 08:41:56 2018-06-07 08:42:47
 |
 |
 |
 |
Date :
2018-06-06 14:52:09 |
By :
nobetaking |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันฟ้องว่าผิดLineที่24ครับ

Code (PHP)
<html>
<head>
<title>Dr.Boo</title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "localhost";
$userName = "root";
$userPassword = "root";
$dbName = "datacheck";
$conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
$nature = $_POST['nature'];
if ($nature != 'สภาพเรียบร้อย') {
$nature = 'ชำรุดเสียหาย';
}
$sql = "INSERT INTO tb_check (id_no, ch_date, ch_name, ch_inv, ch_po, ch_av, pro_id, pro_name, ch_mr, pro_no, ch_lot, mfg_date, exp_date, nature)
VALUES('".$_POST["id_no"]."','".$_POST["ch_date"]."','".$_POST["ch_name"]."','".$_POST["ch_inv"]."','".$_POST["ch_po"]."','".$_POST["ch_av"]."'
,'".$_POST["pro_id"]."','".$_POST["pro_name"]."','".$_POST["ch_mr"]."','".$_POST["pro_no"]."','".$_POST["ch_lot"]."','".$_POST["mfg_date"]."'
,'".$_POST["exp_date"]."','".$_POST["$nature"]."')";
$query = mysqli_query($conn,$sql);
if($query) {
echo "Success";
}
Else
{
echo "Not";
}
mysqli_close($conn);
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2018-06-06 15:04:25 |
By :
community2017 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ออ โทดทีครับผมรำผิดกลอน
Code (PHP)
<html>
<head>
<title>Dr.Boo</title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "localhost";
$userName = "root";
$userPassword = "root";
$dbName = "datacheck";
$conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
$nature = $_POST['nature'];
if ($nature != 'สภาพเรียบร้อย') {
$nature = 'ชำรุดเสียหาย';
}
$sql = "INSERT INTO tb_check (id_no, ch_date, ch_name, ch_inv, ch_po, ch_av, pro_id, pro_name, ch_mr, pro_no, ch_lot, mfg_date, exp_date, nature)
VALUES('".$_POST["id_no"]."','".$_POST["ch_date"]."','".$_POST["ch_name"]."','".$_POST["ch_inv"]."','".$_POST["ch_po"]."','".$_POST["ch_av"]."'
,'".$_POST["pro_id"]."','".$_POST["pro_name"]."','".$_POST["ch_mr"]."','".$_POST["pro_no"]."','".$_POST["ch_lot"]."','".$_POST["mfg_date"]."'
,'".$_POST["exp_date"]."','$nature')";//ใส่ตัวแปรไปเลยครับไม่ต้องใส่ POST
$query = mysqli_query($conn,$sql);
if($query) {
echo "Success";
}
Else
{
echo "Not";
}
mysqli_close($conn);
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2018-06-07 08:40:48 |
By :
nobetaking |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|