You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
784 B
PHP

<?php
include('config.inc.php');
$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'], $config['dbuser'], $config['password'], [
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'"
]);
header ('Content-type: application/json; charset=utf-8');
$lineId = isset($_GET[lineId]) ? intval($_GET[lineId]) : 0;
$result = array('res' => 0, 'data' => array());
if (!$lineId)
{
echo json_encode($result, JSON_UNESCAPED_UNICODE);
}
$stmt = $db->prepare("SELECT `id`,`name` FROM `towers` WHERE line_id=:lineid AND `status`=1 ORDER BY `order`,`id`");
$stmt->execute(array('lineid' => $lineId));
$result['data'] = $stmt->fetchAll();
$stmt = null;
echo json_encode($result, JSON_UNESCAPED_UNICODE);