www/gethopsources.php

Wed, 15 Jul 2020 16:03:23 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 15 Jul 2020 16:03:23 +0200
changeset 705
d77b723f7b35
parent 296
69fadd1aded2
child 771
9856238e9217
permissions
-rw-r--r--

Make sure enumerated values are not empty in database updates. On several data queries set the database connection to UTF-8.

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

$query = "SELECT * FROM inventory_hops ORDER BY origin,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)) {
	$hops[] = array(
		'record' => $row['record'],
		'name' => $row['name'],
		'alpha' => $row['alpha'],
		'beta' => $row['beta'],
		'humulene' => $row['humulene'],
		'caryophyllene' => $row['caryophyllene'],
		'cohumulone' => $row['cohumulone'],
		'myrcene' => $row['myrcene'],
		'hsi' => $row['hsi'],
		'total_oil' => $row['total_oil'],
		'type' => $row['type'],
		'form' => $row['form'],
		'origin' => $row['origin'],
		'inventory' => $row['inventory'],
		'cost' => $row['cost']
	);
}
header("Content-type: application/json");
echo json_encode($hops);

mercurial