<?php
if(!isset($freqp)) { $freqp = 'freq'; }
if($freqp == 'freq' ) {
	$addfreq = 'freq.h_inscription, freq.h_inscription2, freq.h_inscription3, freq.h_sortie, freq.h_sortie_2, freq.h_sortie_3, freq.cas, ';
}
else { $addfreq = 'freq.statut, '; }
//sélection des élèves (si groupe)
if(isset($groupe)) {
	$inscrits_select = "SELECT freq.".$freqp."_id, freq.eleves_id, freq.date_".$freqp.", freq.code_activ, freq.hor_name, ".$addfreq." espaces.espace_id, espaces.espace_nom, eleves.eleves_id, eleves.nom, eleves.prenom, eleves.division 
	FROM ".$prefix."_".$freqp." freq 
	INNER JOIN ".$prefix."_eleves eleves
	ON freq.eleves_id = eleves.eleves_id
	INNER JOIN ".$prefix."_groupele groupele
	ON eleves.eleves_id = groupele.eleves_id 
	INNER JOIN ".$prefix."_groupes groupedesc 
	ON groupele.groupe_id = groupedesc.groupe_id 
	LEFT JOIN ".$prefix."_espaces espaces
	ON espaces.espace_id = freq.espace_id
	".$filtre1.$filtre2.$filtre3."  
	".$ordre."";
	$inscrits = mysqli_query($bdd,$inscrits_select);
	$inscrits_info = mysqli_fetch_assoc($inscrits);
	$nb_inscrits = mysqli_num_rows($inscrits);
}
//sélection des élèves (hors groupes)
else {
	$inscrits_select = "SELECT freq.".$freqp."_id, freq.eleves_id, freq.date_".$freqp.", freq.code_activ, freq.hor_name, ".$addfreq." espaces.espace_id, espaces.espace_nom, eleves.eleves_id, eleves.nom, eleves.prenom, eleves.division 
	FROM ".$prefix."_".$freqp." freq 
	INNER JOIN ".$prefix."_eleves eleves
	ON freq.eleves_id = eleves.eleves_id
	LEFT JOIN ".$prefix."_espaces espaces
	ON espaces.espace_id = freq.espace_id
	".$filtre1.$filtre2.$filtre3."  
	".$ordre."";
	$inscrits = mysqli_query($bdd,$inscrits_select);
	$inscrits_info = mysqli_fetch_assoc($inscrits);
	$nb_inscrits = mysqli_num_rows($inscrits);
}

?>
