Fri, 28 Sep 2018 17:29:23 +0200
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
22 | 1 | <?php |
2 | ||
3 | require($_SERVER['DOCUMENT_ROOT']."/config.php"); | |
4 | require($_SERVER['DOCUMENT_ROOT']."/version.php"); | |
5 | ||
6 | #Connect to the database | |
7 | $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); | |
8 | if (! $connect) { | |
9 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); | |
10 | } | |
11 | ||
12 | // get data and store in a json array | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
13 | $query = "SELECT * FROM profile_water ORDER BY name"; |
22 | 14 | if (isset($_GET['insert'])) { |
15 | // INSERT COMMAND | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
16 | $sql = "INSERT INTO `profile_water` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); |
22 | 17 | $sql .= "', calcium='" . $_GET['calcium']; |
18 | $sql .= "', bicarbonate='" . $_GET['bicarbonate']; | |
19 | $sql .= "', sulfate='" . $_GET['sulfate']; | |
20 | $sql .= "', chloride='" . $_GET['chloride']; | |
21 | $sql .= "', sodium='" . $_GET['sodium']; | |
22 | $sql .= "', magnesium='" . $_GET['magnesium']; | |
23 | $sql .= "', ph='" . $_GET['ph']; | |
24 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); | |
25 | $sql .= "', total_alkalinity='" . $_GET['total_alkalinity']; | |
26 | $sql .= "';"; | |
27 | $result = mysqli_query($connect, $sql); | |
28 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
29 | syslog(LOG_NOTICE, "db_profile_water: ".$sql." result: ".mysqli_error($connect)); |
22 | 30 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
31 | syslog(LOG_NOTICE, "db_profile_water: inserted ".$_GET['name']); |
22 | 32 | } |
33 | echo $result; | |
34 | ||
35 | } else if (isset($_GET['update'])) { | |
36 | // UPDATE COMMAND | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
37 | $sql = "UPDATE `profile_water` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); |
22 | 38 | $sql .= "', calcium='" . $_GET['calcium']; |
39 | $sql .= "', bicarbonate='" . $_GET['bicarbonate']; | |
40 | $sql .= "', sulfate='" . $_GET['sulfate']; | |
41 | $sql .= "', chloride='" . $_GET['chloride']; | |
42 | $sql .= "', sodium='" . $_GET['sodium']; | |
43 | $sql .= "', magnesium='" . $_GET['magnesium']; | |
44 | $sql .= "', ph='" . $_GET['ph']; | |
45 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); | |
46 | $sql .= "', total_alkalinity='" . $_GET['total_alkalinity']; | |
47 | $sql .= "' WHERE record='" . $_GET['record'] . "';"; | |
48 | $result = mysqli_query($connect, $sql); | |
49 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
50 | syslog(LOG_NOTICE, "db_profile_water: ".$sql." result: ".mysqli_error($connect)); |
22 | 51 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
52 | syslog(LOG_NOTICE, "db_profile_water: updated record ".$_GET['record']); |
22 | 53 | } |
54 | echo $result; | |
55 | ||
56 | } else if (isset($_GET['delete'])) { | |
57 | // DELETE COMMAND | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
58 | $sql = "DELETE FROM `profile_water` WHERE record='".$_GET['record']."';"; |
22 | 59 | $result = mysqli_query($connect, $sql); |
60 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
61 | syslog(LOG_NOTICE, "db_profile_water: ".$sql." result: ".mysqli_error($connect)); |
22 | 62 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
63 | syslog(LOG_NOTICE, "db_profile_water: deleted record ".$_GET['record']); |
22 | 64 | } |
65 | echo $result; | |
66 | ||
67 | } else { | |
68 | // SELECT COMMAND | |
69 | $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); | |
70 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { | |
71 | $waters[] = array( | |
72 | 'record' => $row['record'], | |
73 | 'name' => $row['name'], | |
74 | 'calcium' => $row['calcium'], | |
75 | 'bicarbonate' => $row['bicarbonate'], | |
76 | 'sulfate' => $row['sulfate'], | |
77 | 'chloride' => $row['chloride'], | |
78 | 'sodium' => $row['sodium'], | |
79 | 'magnesium' => $row['magnesium'], | |
80 | 'ph' => $row['ph'], | |
81 | 'notes' => $row['notes'], | |
82 | 'total_alkalinity' => $row['total_alkalinity'] | |
83 | ); | |
84 | } | |
85 | echo json_encode($waters); | |
86 | } | |
87 | ?> |