<?php

   include "pdo_connection.php";

   $chrsql = "";
   $values = array();

   if($_REQUEST["lc"] != "") {
       $chrsql = "WHERE Group_CHAR = ?";
       $values[] = $_REQUEST["lc"];
   }
   
   $sql = "SELECT ID AS Artist_ID, Name AS Artist_Name FROM _9a_arist ".$chrsql." ORDER BY Name";

   $stmt = $pdo->prepare($sql);
   $stmt->execute($values);

   $rows   = array();

   if($stmt->rowCount() == 0) echo "No artists.";
   else {
      while($row = $stmt->fetch()) {
         $row_array["Artist_ID"] = $row["Artist_ID"];
         $row_array["Artist_Name"] = $row["Artist_Name"];
         array_push($rows, $row_array);
      }
      echo json_encode($rows);
   }

?>