1 <?php |
1 <?php |
2 |
2 |
3 require($_SERVER['DOCUMENT_ROOT']."/config.php"); |
3 require($_SERVER['DOCUMENT_ROOT']."/config.php"); |
4 require($_SERVER['DOCUMENT_ROOT']."/version.php"); |
4 require($_SERVER['DOCUMENT_ROOT']."/version.php"); |
|
5 require($_SERVER['DOCUMENT_ROOT']."/includes/constants.php"); |
5 |
6 |
6 #Connect to the database |
7 #Connect to the database |
7 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); |
8 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); |
8 if (! $connect) { |
9 if (! $connect) { |
9 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
10 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
10 } |
11 } |
11 mysqli_set_charset($connect, "utf8" ); |
12 mysqli_set_charset($connect, "utf8" ); |
|
13 |
12 |
14 |
13 // get data and store in a json array |
15 // get data and store in a json array |
14 if (isset($_POST['insert']) || isset($_POST['update'])) { |
16 if (isset($_POST['insert']) || isset($_POST['update'])) { |
15 if (isset($_POST['insert'])) { |
17 if (isset($_POST['insert'])) { |
16 $sql = "INSERT INTO `inventory_yeasts` SET "; |
18 $sql = "INSERT INTO `inventory_yeasts` SET "; |
18 if (isset($_POST['update'])) { |
20 if (isset($_POST['update'])) { |
19 $sql = "UPDATE `inventory_yeasts` SET "; |
21 $sql = "UPDATE `inventory_yeasts` SET "; |
20 } |
22 } |
21 |
23 |
22 $sql .= "name='" . mysqli_real_escape_string($connect, $_POST['name']); |
24 $sql .= "name='" . mysqli_real_escape_string($connect, $_POST['name']); |
23 $sql .= "', type='" . $_POST['type']; |
25 $sql .= "', type='" . array_search($_POST['type'], $yeasttype); |
24 $sql .= "', form='" . $_POST['form']; |
26 $sql .= "', form='" . array_search($_POST['form'], $yeastform); |
25 $sql .= "', laboratory='" . mysqli_real_escape_string($connect, $_POST['laboratory']); |
27 $sql .= "', laboratory='" . mysqli_real_escape_string($connect, $_POST['laboratory']); |
26 $sql .= "', product_id='" . mysqli_real_escape_string($connect, $_POST['product_id']); |
28 $sql .= "', product_id='" . mysqli_real_escape_string($connect, $_POST['product_id']); |
27 $sql .= "', min_temperature='" . $_POST['min_temperature']; |
29 $sql .= "', min_temperature='" . $_POST['min_temperature']; |
28 $sql .= "', max_temperature='" . $_POST['max_temperature']; |
30 $sql .= "', max_temperature='" . $_POST['max_temperature']; |
29 $sql .= "', flocculation='" . $_POST['flocculation']; |
31 $sql .= "', flocculation='" . $_POST['flocculation']; |
88 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); |
90 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); |
89 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
91 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
90 $yeasts[] = array( |
92 $yeasts[] = array( |
91 'record' => $row['record'], |
93 'record' => $row['record'], |
92 'name' => $row['name'], |
94 'name' => $row['name'], |
93 'type' => $row['type'], |
95 'type' => $yeasttype[$row['type']], |
94 'form' => $row['form'], |
96 'form' => $yeastform[$row['form']], |
95 'laboratory' => $row['laboratory'], |
97 'laboratory' => $row['laboratory'], |
96 'product_id' => $row['product_id'], |
98 'product_id' => $row['product_id'], |
97 'min_temperature' => $row['min_temperature'], |
99 'min_temperature' => $row['min_temperature'], |
98 'max_temperature' => $row['max_temperature'], |
100 'max_temperature' => $row['max_temperature'], |
99 'flocculation' => $row['flocculation'], |
101 'flocculation' => $row['flocculation'], |