-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtab_blood_test_exams_mass_save.php
58 lines (42 loc) · 1.25 KB
/
tab_blood_test_exams_mass_save.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
@session_start();
if (!isset($_SESSION["id"])) {
echo json_encode(null);
exit ;
}
if (!isset($_POST['blood_test_id'])){
echo "error010101010";
return;
}
$blood_test_id = intval($_POST['blood_test_id']);
if ($blood_test_id == 0 ){
echo "blood test is not set";
return;
}
//DB
require_once ('general.php');
$db = new dbase();
$db->connect_sqlite();
// if (isset($_POST['3']))
// echo "SDf";
// print_r($_POST);
$posted_exams = $_POST;
//construct the SQL
$insert_sql = "INSERT INTO `blood_test_exams` (blood_test_id, exam_type_id, exam_value) VALUES (:blood_test_id, :exam_type_id, :exam_value)";
//prepare the SQL to destination connection
if ($stmt = $db->getConnection()->prepare($insert_sql)){
foreach($posted_exams as $exam_id => $exam_id_value)
{
if (empty($exam_id_value) || $exam_id == 'blood_test_id' || $exam_id == 'submit')
continue;
$stmt->bindValue(":blood_test_id" , $blood_test_id);
$stmt->bindValue(":exam_type_id" , $exam_id);
$stmt->bindValue(":exam_value" , $exam_id_value);
//execute the prepared statement
$stmt->execute();
if($stmt->errorCode() != "00000"){
echo $stmt->errorCode();
exit;
}
}
}