YEAH !!!!!!!!!!!!!!!!!!!!!!!!!!
YOU GET IT
Thanks THANKS a lot Lars Berg
You get it!!!
Wow, I so happy...
Now, take a look in the full query, the real query 🙂
$select = "select E.Id, E.Nom, E.NumeroCivique, E.AptCode, E.IdRue,
E.NomContact, E.PrenomContact, E.Telephone, E.Poste,
E.Fax, E.EMail, E.DistanceMin, E.DistanceMax, E.Logo, E.LogoRatio,
E.IdStyle, CP.CodePostal ";
$from = "from Etablissements as E, CodePostal as CP ";
$where = "where E.IdCodePostal = CP.Id ";
$order_by = "";
$group_by = "group by E.Id ";
if (isset($F_Prop))
{
$i=0;
while (list($dummy,$value) = each($F_Prop))
$CheckProp[$i++]=$value;
$fin_check_prop = count($CheckProp);
---------------------------
Your code is here Lars Berg
---------------------------
if ($fin_check_prop)
{
for ($i=0; $i<$fin_check_prop; $i++)
{
$from = $from.", EtabProp as EP".$i." ";
$where = $where."AND (EP".$i.".IdEtab=E.Id AND EP".$i.".IdProp=$CheckProp[$i])";
}
if ($F_TypeEtab[0])
{
$from = $from.", EtabType as ET ";
$where = $where."AND ET.IdEtab=E.Id AND (";
$fin_typeetab = count($F_TypeEtab);
for ($i=0; $i<$fin_typeetab; $i++)
{
if ($i)
$where = $where." OR ";
$where = $where."ET.IdType=".$F_TypeEtab[$i];
}
$where = $where.") ";
}
----------- End here -------
if ($Lat_Source || $Long_Source)
{
$select = $select.", 6378ACOS(SIN($A)SIN(CP.Latitude/57.29577951)+COS($A)COS(CP.Latitude/57.29577951)COS($B-(CP.Longitude/57.29577951))) as Distance ";
$order_by = "order by Distance";
}
else
$order_by = "order by E.DistanceMin desc";
$LeEtablissement = @($select.$from.$where.$group_by.$order_by);