<?php

  function partenaire_club($id, $table = "aeroclubs") {
    global $connexion;
	$query = "select $table.id, $table.nom, $table.adresse, ($table.photo is not null) as aphoto from $table, aerodromes where aerodromes.id = $id and ( $table.position <-> aerodromes.position ) < 0.2 order by random() limit 1";
	$result = pg_query_ok($query);
	if (! ($line = @pg_fetch_array($result, 0))) {
	   return 0;   
	}
	print "<partenaire nom=\"$line[nom]\" photo=\"".($line[aphoto]=="t"?"photo.php?site=$line[id]":"")."\">";
	print "<adresse>$line[adresse]</adresse>";
	print "</partenaire>";
	return 1;
  }
  function partenaire_loueur($id) {
    return partenaire_club($id, "loueurs");
  }
  function partenaire_resto($id) {
    return 0;
  }

?>