<?php

  require '../conf/config.php';

  //////////////////////////////////  Connecting with DB
  $conn = mysql_connect($host, $user, $pswd);
  $db = mysql_select_db($db);

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

  ////////////////////////////////////////////////////////// List of accessions
  $ids = array();
  $rates = array();
  $query = "SELECT accession, rate FROM sys_snpblock where accession like '%".$prm_accession."%'";
  $result = mysql_query($query);
  while ($row = mysql_fetch_row($result)) {
    $ids[]=$row[0];
    $rates[]=$row[1];
  }

  $str="[";
  for ($i=0; $i<count($ids); $i++) {
    $str=$str."{\"id\":\"".$ids[$i]."\",\"rate\":\"".$rates[$i]."\"}"; 
    if ( $i<count($ids)-1 ) {
      $str=$str.",";
    }
  }
  $str=$str."]";

  echo $str;

?>

