<?php
header('Content-type: application/json');
include '../config/database.php';
function _get_result($name){
	$conn = _connectDB();
	$sql = "SELECT * FROM temp_stock WHERE stock_name = '".$name."' AND stock_three != '' AND stock_two != ''  ORDER BY stock_id DESC  LIMIT 30";
	$result = $conn->query($sql);
	$res = [];
	if ($result->num_rows > 0) {
	    while($row = $result->fetch_assoc()) {
			array_push($res,$row);
	    }
	} else {
	    echo "";
	}
	return $res;
}

$_name = $_GET['name'];
echo json_encode(_get_result($_name));
