<?php 

	$users = mysql_select_query("SELECT state, count(num) as users_count FROM urbanhal_members GROUP BY state");

	$data = [];

	foreach($users as $user){

		$data[$user['state']] = '<div>Users : ';

		$data[$user['state']] .= "<span class='state_listings_count'>". $user['users_count'] ."</span></div>";

	}

	$listings = mysql_select_query("SELECT state, count(num) as listings_count FROM urbanhal_listings GROUP BY state");

	foreach($listings as $key => $listing){
		if(!array_key_exists($listing['state'], $data)){
			$data[$listing['state']] = '<div>Users : ';

			$data[$listing['state']] .= "<span class='state_listings_count'>0</span></div>";
		}
		@$data[$listing['state']] .= '<div>Listings : ';

		@$data[$listing['state']] .= "<span class='state_listings_count'>". $listing['listings_count'] ."</span></div>";
	}

	echo json_encode($data);


?>