<?php

function DB()
{	
	$site = $_SERVER["SERVER_NAME"];	
	
	if( ($site == "localhost") || ($site == "127.0.0.1") )
	{		
			$db_host    = "localhost";	 
			$db_user   = "root";	  
			$db_pass   = ""; 
			$db_name   = "test";
	}	
	
	else 
	{  
			$db_host    = "analogdepat.mysql.db";   
			$db_user   = "analogdepat"; 	   
			$db_pass   = "Un92pac007";	    
			$db_name   = "analogdepat";	
	}		

	$connexion = mysqli_connect($db_host,$db_user,$db_pass); 	

	if(!$connexion)
	{	
		die('Could not connect: ' . mysql_error());		
    }

	mysqli_select_db($connexion, $db_name); 		
	return($connexion);

}	

	$connexion = DB(); 

	//$sql = "SELECT * FROM client" ;
	$sql = "SELECT * FROM table_jeu" ;
	
	mysqli_query($connexion, "SET NAMES 'utf8'");
	$result = mysqli_query($connexion, $sql );

	$rows = array();
	
	$response["products"] = array();

	
	while ($datas = mysqli_fetch_assoc ($result))
	{
		 $rows[] = $datas; 
		 
		 $product = array();
		 $product["id"] = $datas["id"];
         $product["nom"] = $datas["nom"];
 
        // push single product into final response array
        array_push($response["products"], $product);

		
	}

	//echo json_encode($rows);	
	
    $response["success"] = 1;
 
    // echoing JSON response
    echo json_encode($response);



?>