<?php
require_once ("varables.php");

$myJSON['rout'] = array();
$myJSON['success']="0";
if(isset($_POST["nekot"]) && isset($_POST["an1d"]))
{
    $id =$_POST["an1d"];
    $connect = @mysqli_connect($hostname,$username,$password,$database);
    if($connect)
    {
        @mysqli_query($connect,"SET CHARACTER SET utf8;");
		if($id == 0 || $id ==null){
			$query_all = "SELECT * FROM ".$tbl_routs;
			$allres = @mysqli_query($connect,$query_all);
			if($allres){
			 while($row = @mysqli_fetch_assoc($allres))
				array_push($myJSON["rout"], $row);
				$myJSON['success']="200";
			}
		}
		else if($id >0){
			$query_one = "SELECT * FROM ".$tbl_routs." WHERE id = '".$id."'";
			$oneres = @mysqli_query($connect,$query_one);
			if($oneres){
			 while($row = @mysqli_fetch_assoc($oneres))
				array_push($myJSON["rout"], $row);
				$myJSON['success']="200";
			}
		}
		
	}
	 else
		 $myJSON['success']="402";
}
echo json_encode($myJSON);
?>