<?php

sleep(1);
if (array_key_exists("mque", $_REQUEST))
{
	$tomorrow = 0;//60*60*24; // en nb de secondes
	header("Cache-Control: max-age=$tomorrow");
	print_plain();
}
else
{
	print "Usage : $_SERVER[PHP_SELF]?mque=un-code-marque";
}

function print_plain()
{
	header("Content-type: text/html; charset=windows-1252");
	$types = get_types($_REQUEST["mque"]);
	$result = array();
	foreach ($types as $row)
	{
		$result[] = $row["rltl_code"]."=".$row["rltl_desc"];
	}
	print implode(";", $result);
}

function get_types($mque)
{
	include_once("../inc/config.inc.php");
	include_once("../inc/func_txt.inc.php");
	// On se connecte a la base
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	// On recupere les enregistrements
	$rech = "SELECT * FROM ".TBRLTL." WHERE rltl_codema='".str_majuscules($mque)."' OR rltl_codema='*' ORDER BY rltl_desc";
	$rs = mysql_query($rech) or die(mysql_error());
	// On cree le resultat
	$result = array();
	while($row = mysql_fetch_array($rs))
	{
		$result[] = $row;
	}
	mysql_close();
	return $result;
}

?>