<?php
   
	$servername = "localhost";
	$dbuser = "plexusrs";
	$dbpass = "sTUmTaQsSsPtRJy";
	$dbname = "newsplex_db";
    
    //get search term
    $searchterm = $_GET['term'];
	$year2015='2015';
	
	try {
	$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbuser, $dbpass);
	// set the PDO error mode to exception
	$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	
	$sthandler = $conn->prepare("select victim_names from police_killings where year(date_of_incident)=:year2015 and victim_names like '%".$searchterm."%' order by victim_names asc");
	$sthandler->bindParam(':year2015', $year2015);
	$sthandler->execute();
	$name = $sthandler->fetchAll();
	foreach ($name as $row) {
	$data[] = $row['victim_names'];
	}
	//return json data
    echo json_encode($data);
	}
	catch(PDOException $e)
	{
	echo "error" . "<br>" . $e->getMessage();
	}
	$conn = null;
    
    
?>