<?php

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

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

  ////////////////////////////////// prepare 
  
  $phenotypes = array();
  $str;
  
  $str="[";
  
  $queryP = "SELECT phenotype_id, phenotype FROM sys_phenotype order by phenotype_id";
  $stmtP = $conn->stmt_init();
  $stmtP->prepare($queryP);
  $stmtP->execute();
  $stmtP->store_result();
  $stmtP->bind_result($row0,$row1);
  
  $phenotypes = array();
  while ($stmtP->fetch()) {
  	$phenotypes[$row0] = $row1;
  }
  
  $stmtP->close();
   
  foreach($phenotypes as $phenotype_id => $phenotype) {
  	$str .= '{"phenotype":"' .$phenotype. '"},';
  }
  $str = rtrim($str, ',');
  $str=$str."]";

  echo $str;
?>

