<?php
$db = mysqli_connect("localhost","root","","phpmyadmin");
class send_data
{
	public $db;
	public $txt;
	public function send($db,$txt)
	{
		mysqli_query($db,$txt);
		$data['a'] = 1;
		echo json_encode($data);
	}
	public function request($db,$txt)
	{
		$query = mysqli_query($db,$txt);
		while($row = mysqli_fetch_assoc($query))
		{
			$data[] = $row;
		}
		echo json_encode($data);
    }
    public function get_num($db,$txt)
    {
		$query = mysqli_query($db,$txt);
		$num = mysqli_num_rows($query);
		$data['num'] = $num;
		echo json_encode($data);
	}


}
$type = $_POST['type'];
$txt = $_POST['txt'];
if($type == 0)
{
	$send = new send_data();
	$send->db = $db;
	$send->txt = $txt;
	$send->send($db,$send->txt);
}
if($type == 1)
{
	$request = new send_data();
	$request->db = $db;
	$request->txt = $txt;
	$request->request($db,$request->txt);
}
if($type == 2)
{
	$num = new send_data();
	$num->db = $db;
	$num->txt = $txt;
	$num->get_num($db,$num->txt);
}

?>