www/getwatersources.php

Fri, 18 Jun 2021 15:26:55 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 18 Jun 2021 15:26:55 +0200
changeset 754
30abc8024afe
parent 705
d77b723f7b35
child 771
9856238e9217
permissions
-rw-r--r--

The php/ajax combo for split btaches is the first that will do a better job handling errors. Split batch leftover calculations rounded to 1 decimal. Refuse to split and leave nothing in the main batch

<?php
require_once('config.php');

$query = "SELECT * FROM inventory_waters ORDER BY name";
$connect = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
if (! $connect) {
	echo "[]";
	return;
}
mysqli_set_charset($connect, "utf8");
$result = mysqli_query($connect, $query);
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
	$waters[] = array(
		'record' => $row['record'],
		'name' => $row['name'],
		'unlimited_stock' => $row['unlimited_stock'],
		'calcium' => $row['calcium'],
		'sulfate' => $row['sulfate'],
		'chloride' => $row['chloride'],
		'sodium' => $row['sodium'],
		'magnesium' => $row['magnesium'],
		'ph' => $row['ph'],
		'total_alkalinity' => $row['total_alkalinity'],
		'inventory' => $row['inventory'],
		'cost' => $row['cost']
	);
}
header("Content-type: application/json");
echo json_encode($waters);

mercurial