Bonjour je souhaierais de l'aide sur une fonction

Voici ma fonction
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
 function getdetailssoustype2($id)
        {
        $db = & JFactory :: getDBO();
        $query = 'select * from #__f_soustype where id = '.$id.'' ;
        $db->setQuery($query);
        $result = $db->loadobject();
        $query = 'select nom , id_group from #__f_type where id = '.$result->id_type.'' ;
        $db->setQuery($query);
        $type = $db->loadobject();
        $query = 'select nom  from #__f_group where id = '.$type->id_group.'' ;
		$age_max = $db->loadobject();
        $query = 'select from jos_f_evenement where age_max <=18';
		$db->setQuery($query);
        $group = $db->loadresult();
        $array['soustype'] = $result;
        $array['type'] = $type->nom;
        $array['group'] = $group;
		$array['age_max'] = $age_max;
 
 
        return $array;
 
        }
Cette fonction normalement devrait afficher uniquement les resultats ou l'age max est inférieur à 18, mais je ne sais pas pourquoi cela ne fonctionne pas.

Voici ma page qui appelle ma fonction

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
<?php defined('_JEXEC') or die('Restricted access');
if( class_exists( "JATJPConfig" ) ) {
    $conf = new JATJPConfig();
}
$session =& JFactory::getSession();
//$css = JURI::base().'components/com_formation/assets/style.css';
$document =& JFactory::getDocument();
//$document->addStyleSheet($css);
JHTML::_('behavior.mootools');
$js ="
function ajoutauselection(id){
$('sel'+id).setHTML('');
url = 'index2.php?option=com_formation&view=categorie&c=categorie&task=ajoutauselection&id='+id;
var myRequest = new Ajax(url,{
method: 'get',
onSuccess: function(responseText) {
alert(responseText);

}}).request();
}";
$document->addScriptDeclaration($js);
jimport('joomla.html.html');
JRequest :: setVar('layout', 'default');
$js = "window.addEvent('domready', function(){";
$selection = $session->get('selection',false);
 
//effacer les encient demande de session
$pagenation = $this->pagination;
$model = $this->model;
$params = $this->params;
$option = $this->option;
$items  = $this->items;
$id=JRequest::getvar('id',0);
 
?>
 
 
 <br />   <table width="100%"><tr><td valign="top">
<?php
 
if(count($items)){
	$id_soustype = '';
foreach ($items as $item) {
 
    if($item->id_soustype != $id_soustype) {
		if( !empty($id_soustype) )
  echo "</div>";
 
        $id_soustype = $item->id_soustype;
        $detailssoustype2 = $model->getdetailssoustype2($id_soustype);
        $image = $detailssoustype2['soustype']->image;
        $nomsoustype = $detailssoustype2['soustype']->nom;
        $nomtype = $detailssoustype2['type'];
        echo '<div class="listlist">';
        echo '<table width="100%" height="100%"><tr><td><img height ="139"  src ="images/formation/soustype/'.$image.'" /></td><td width="100%" height="100%">';
        echo '<div class="labeltxt"><label class="group">'.$detailssoustype2['type'].'</label><br><label class="type"> '.$detailssoustype2['soustype']->nom.'</label></div>';
        echo '</td><td><img height ="139"  src ="images/formation/soustype/'.$image.'" style="padding-left:10px" /></td></tr></table></div><div class="around-border"></div>';
		echo '<div style="overflow:auto; height:197px; width:600px">';
    }
 
 
    $detailssoustype2 = $model->getdetailssoustype2($item->id_age_max);
    if($item->image_list)
    $image = 'images/formation/image_list/'.$item->image_list;
    else
    $image = 'images/formation/soustype/'.$detailssoustype2['soustype']->image;
    echo '<div class="listlist2">';
    echo '<table width="100%" heigh="100%"><tr><td width="139">';
    echo '<label class="soustype'.$model->getlieunom2($item->lieu).'">'.$model->getlieunom($item->lieu).'</label>';
    echo '</td><td width="385" height="100%"><table width="100%" height="100%" ><tr><td colspan="2">';
    echo '</td></tr><tr><td valign="bottom">';
    echo '<b>'.JText::_('Age ').'</b>'.$item->age_afficher.'&nbsp;>&nbsp;<b>'.JText::_('Niveau ').'</b> '.$item->niveau.'<br>';
    echo '<b>'.JText::_('Animé par ').'</b>'.$model->getnomanimateur($item->id_animateur).'<br>';
    echo ''.$item->date_afficher.'&nbsp;'.$item->horaire_debut.'-'.$item->horaire_fin.'';
    echo '';
    echo '</td><td width="33%" valign="bottom" align="right">';
    echo '<b>'.$item->statut.'</b><br>';
    if(@!in_array($item->id, $selection))
    echo '<div id="sel'.$item->id.'"><input type="button" class="selectionner" onclick="ajoutauselection('.$item->id.')" /></div>';
    echo '<a href="index.php?option=com_formation&view=details&id='.$item->id.'" class="link"> >> Lire la suite</a>';
    echo '</td></tr></table></td></tr></table>';
    echo '</div>';
 
	}
 echo '</div>';
 
echo $pagenation->getListFooter();
}
else
{
    echo 'Pas des articles';
}
 
?>
        </td></tr></table>
Si quelqu'un pouvez me dire ou sa bloque.

Merci d'avance.