<?php
/*
* targetTrack.php
* http://tasuke.dna.affrc.go.jp/
*
* Author: Norio Tabei
*
* Copyright (c) 2019 National Institute of Agrobiological Sciences   
*
*/

require '../conf/config.php';
////////////////////////////////// Connecting with DB
if( !$conn = new mysqli($host, $user, $pswd, $db)) {
    error_log("Connection failed.\n");
    exit;
}

////////////////////////////////// Parameters
(isset($_GET['prm_Seq']) && !empty($_GET['prm_Seq'])) ? $prm_Seq=$_GET['prm_Seq'] : returnError("Error");

///////////////////////////////////////////////////////////////////////////////
// Track
///////////////////////////////////////////////////////////////////////////////
$query = "SELECT seq,track,chr,id,name,parent,type,pos,end,strand,note,others FROM sys_track WHERE seq=?";
$stmt = $conn->stmt_init();
$stmt->prepare($query);
$stmt->bind_param("i", $prm_Seq);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($seq,$track,$chr,$id,$name,$parent,$type,$pos,$end,$strand,$note,$others);

$arr = "";
if ($stmt->fetch()) {
	$arr = array(
		'seq'	=> $seq,
		'track'	=> $track,
		'chr'	=> $chr,
		'id'	=> $id,
		'name'	=> $name,
		'parent'	=> $parent,
		'type'	=> $type,
		'pos'	=> $pos,
		'end'	=> $end,
		'strand'	=> $strand,
		'note'	=> $note,
		'others'	=> $others
	);
}
$stmt->close();

mysqli_close($conn);

echo json_encode($arr);

function returnError($str){
    echo $str;
}

function _stopError($str){
    echo $str;
    exit;
}
?>

