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
|
<?php
include('FichierExcel.php');
//accès à la la base de données
mysql_connect("localhost","root","") or die("La connexion a échoué !");
// on sélectionne la base
mysql_select_db("*");
$i=0;
$fichier = new FichierExcel();
// Tab en-tête, juste pour ajouter un élement qui nous servira plutard
$tab_entete = array('Projet');
$requete="SELECT distinct nom_projet FROM pourcentage";
$resultat = mysql_query ($requete);
//Création d'une Table avec tous les ID_eleve
while ( $row = mysql_fetch_object($resultat))
{
$tab_nom_projet[] = $row->nom_projet;
}
foreach ($tab_nom_projet as $key=>$nom_projet)
{
$requete1="SELECT distinct pourcentage.nom_projet, users.nom, pourcentage.valeur_pourcentage FROM projet, users, pourcentage
WHERE pourcentage.nom_projet='".$nom_projet."'";
$resultat1 = mysql_query ($requete1);
$lignes = mysql_num_rows ($resultat1);
$tab_user = array();
$tab_pourcentage = array();
$tab_pro = array();
if ($lignes!=0) {
$i = $i+1;
while ($row1 = mysql_fetch_object($resultat1))
{
$tab_user[] = $row1->nom;
$tab_pourcentage[] = $row1->valeur_pourcentage;
$tab_pro[] = $row1->nom_projet;
}
}
if ($i=="1")
{
// Fusion des deux tableau Tab_entete et matière
$tab_temp= array_merge($tab_entete, $tab_user);
// ont explose les tableau pour les préparé a les mettre dans les fichier
$list_user= implode(";", $tab_temp);
//le resultat de l'explosion se met dans un fichier CSV selon la class $list_mat
$fichier->Colonne($list_user);
}
// Table nom nous donne a chaque boucle le même nom, nous demandons d'effacé les doublon
$tab_pro = array_unique($tab_pro) ;
// Fusion des deux tableau Tab_nom et note
$tab_temp2= array_merge($tab_pro, $tab_pourcentage);
// ont explose les tableau pour les préparé a les mettre dans les fichier
$list_pourcent= implode(";", $tab_temp2);
$fichier->Insertion($list_pourcent);
}
$fichier->output('NomFichier');
?> |
Partager