job_no is primaary key
i want save description as array, when i insert many description to one job in database, last description only saved in saved database i can't see other descriptions.
var_dump($description)
: ??
html
: ??
php:
<?php
include ("connection.php");
$sel_type = $_POST["type"];
$ref_no = $_POST["refno"];
$in_date = date("Y-m-d", strtotime($_POST['date']));
$inv_to = $_POST["to"];
$inv_attn = $_POST["attn"];
$job_no = $_POST["jobno"];
$subject = $_POST["subject"];
$description = $_POST["descrip"];
if(!$_POST["submit"]){
echo "please fill out";
header('Location: index.php');
}
else{
if($description){
foreach($description as $c){
$sql = "INSERT INTO student(sel_type,ref_no,in_date,inv_to,inv_attn,job_no,subject,description)
VALUES('$sel_type','$ref_no','$in_date','$inv_to','$inv_attn','$job_no','$subject','$c')";
}}
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>