IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

PHPExcel vers mysql


Sujet :

Langage PHP

  1. #1
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut PHPExcel vers mysql
    Bonjour,

    J'essaye d'importer un fichier excel dans mysql mais je n'y arrive pas..




    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
    // WIP
    	//A terme permettra d'enregistrer des élèves dans la base de donnée à partir d'un fichier excel
    	//Document type utilisé : ElevesComplete.xls
    	public function registerCSV($fichier){
     
     
    		try{
    		require 'coBDD.php';
    		require 'PHPExcel.php';
    		require_once 'PHPExcel/IOFactory.php';
     
    		$objectReader = PHPExcel_IOFactory::createReader('Excel2007');
        	$objectReader->setReadDataOnly(true);
     
    		$objPHPExcel = $objectReader->load($fichier);
        	$objWorksheet = $objPHPExcel->setActiveSheetIndexbyName('Sheet1');
     
    		}catch (Exception $e){
    			die('Erreur : ' . $e->getMessage());
    		}
    		// c'est ici que les grecs et les romains s'empoignèrent c chelou
    		include('coBDD.php');
    		require('PHPExcel.php');
    		require('PHPExcel/Reader/Excel2007.php');
     
    		try {
    		    $inputFileType = PHPExcel_IOFactory::identify($fichier);
    		    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    		    $objPHPExcel = $objReader->load($fichier);
    		} catch (Exception $e){
    			die('Erreur : ' . $e->getMessage());
    		}
     
    		$sheet = $objPHPExcel->getSheet(0);
    		$highestRow = $sheet->getHighestRow(); 
    		$highestColumn = $sheet->getHighestColumn();
     
    		$query = $db->prepare('INSERT INTO ELEVE (INE, libClasse, prenom1Eleve) VALUES ( :INE, :classe, :prenom)');
     
    		for($i=2;$i<=$higestRow;$i++){
     
    			$num=$objPHPExcel->getActiveSheet()->getCell(1,$i)->getValue();
    			$classe=$objPHPExcel->getActiveSheet()->getCell(2,$i)->getValue();
    			$prenom=$objPHPExcel->getActiveSheet()->getCell(3,$i)->getValue();
     
    			$query->bindValue(':INE',$num, PDO::PARAM_INT);
    			$query->bindValue(':classe',$classe, PDO::PARAM_STR);
    			$query->bindValue(':prenom',$prenom, PDO::PARAM_STR);
     
    			$query->execute();
     
    		}
     
    		$db = null;
    	}


    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
    // Crée un fichier excel à télécharger avec la liste des élèves
    	public function setXls(){
    			include('coBDD.php');
     
    			$query = $db->prepare('SELECT * FROM ELEVE ORDER BY nomEleve');
    			$query->execute();
     
    			require('PHPExcel.php');
    			require('PHPExcel/Writer/Excel2007.php');
     
    			// Instanciation de l'objet PHPExcel
    			$objPHPExcel = new PHPExcel;
     
    			// Définie le nom du créateur du fichier, on prend ici le nom d'utilisateur
    			$objPHPExcel->getProperties()->setCreator($_SESSION['username']);
     
    			// Définition de la feuille active
    			$objPHPExcel->setActiveSheetIndex(0);
     
    			// Définition du titre de l'onglet
    			$objPHPExcel->getActiveSheet()->setTitle('Liste complète élève'); 
     
    			// Création du titre de chaque colonnes
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 1, 'N°INE');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 1, 'Sexe');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 1, 'Nom');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, 1, 'Classe');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, 1, '1er Prenom');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, 1, '2eme Prenom');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, 1, '3emePrenom');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, 1, 'Date de Naissance');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, 1, 'Groupes Langues');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(9, 1, 'Options');
    			$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(10, 1, 'MEF');
     
    			// Mise en page de la feuille Excel
    			$styleA1 = $objPHPExcel->getActiveSheet()->getStyle('A1:K1'); // Instanciation la classe PHPExcel_Style, on passe la  ou les cellules visée en paramètre
    			$styleFont = $styleA1->getFont(); // Instanciation de la classe PHPExcel_Style_Font
    			$styleFont->setBold(true);	// Passage à true pour mettre la ou les cellules en gras
     
    			// Définition de la taille des colonnes.
    			$objPHPExcel->getActiveSheet()->getColumnDimension("A")->setWidth(15);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("B")->setWidth(5);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("C")->setWidth(20);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("D")->setWidth(8);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("E")->setWidth(15);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("F")->setWidth(15);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("G")->setWidth(15);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("H")->setWidth(18);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("I")->setWidth(17);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("J")->setWidth(8);
    			$objPHPExcel->getActiveSheet()->getColumnDimension("K")->setWidth(30);
     
    			$i = 2;
    			while($data = $query->fetch()){
    				$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $i, $data['INE']);
    				$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $i, $data['sexe']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $i, $data['nomEleve']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $i, $data['libClasse']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $i, $data['prenom1Eleve']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $i, $data['prenom2Eleve']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $i, $data['prenom3Eleve']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $i, $data['dateNaissance']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $i, $data['libGroupeLV1'].$data['libGroupeLV2']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(9, $i, $data['libOption']);
    	            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(10, $i, $data['MEF']);
    				$i++;
    			}
     
    			$db = null;
     
    			header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); 
    			header('Content-Disposition: attachment;filename="Liste complète élève.xlsx"'); 
    			header('Cache-Control: max-age=0'); 
     
    			$writer = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); 
        		$writer->save('php://output');
     
    	}
    Classe admin
    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
    function importXls(){
     
            $eleve = new Eleve();
            try{
        		require 'classes/coBDD.php';
        		require 'classes/PHPExcel.php';
     
        		// Chargement du fichier Excel
        		require_once 'classes/PHPExcel/IOFactory.php';
     
        		$objectReader = PHPExcel_IOFactory::createReader('Excel2007');
            	$objectReader->setReadDataOnly(true);
     
        		$inputFileType = PHPExcel_IOFactory::identify('ElevesComplete.xlsx');
     
        		$objectReader = PHPExcel_IOFactory::createReader($inputFileType);
            	$objectReader->setReadDataOnly(true);
     
        		$objPHPExcel = $objectReader->load($_GET['fichier']); 
            	$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
     
    		}catch (Exception $e){
    			die('Erreur : ' . $e->getMessage());
    		}
            //$eleve->registerCSV($_GET['fichier']);
            //$message = '<p style="color: green;">Le fichier a bien été enregistré dans la base de données.</p>';
            require('view/import.php');
    j'en suis là pour l'instant..

    Merci

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Si tu ne nous dis pas ou tu bloques, le résultat que tu obtiens, les débugages que tu as déjà fait ...
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut
    j'ai ça tout le temps

    Not Found

    The requested URL /admin.php was not found on this server.
    Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Et c'est quoi ce fichier admin.php ?
    A quelle endroit de ton code on cherche à atteindre ce fichier ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  5. #5
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut
    Bon bah en fait c'est bon c'était juste le chemin qui était mal renseigné

  6. #6
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut
    Bon au final j'ai une autre erreur dans la classe admin sur cette ligne :

    $objPHPExcel = $objectReader->load($_GET['fichier']);

    Undefined index : fichier in C:\wamp\www\workspace\admin.php on line 278

    La classe import si besoin :
    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
    97
    98
    99
    100
    <?php
    include('include/header.php');
    if(!empty($message)){ echo $message; }
    ?>
    	<script language="javascript">
    		function change_onglet(name)
                    {
                            document.getElementById('onglet_'+anc_onglet).className = 'onglet_0 onglet';
                            document.getElementById('onglet_'+name).className = 'onglet_1 onglet';
                            document.getElementById('contenu_onglet_'+anc_onglet).style.display = 'none';
                            document.getElementById('contenu_onglet_'+name).style.display = 'block';
                            anc_onglet = name;
                    }
     
    	</script>
     
    	<style type="text/css">
            .onglet
            {
                    display:inline-block;
                    margin-left:3px;
                    margin-right:3px;
                    padding:3px;
                    border:1px solid black;
                    cursor:pointer;
    				color: black;
            }
            .onglet_0
            {
                    background:#bbbbbb;
                    border-bottom:1px solid black;
            }
            .onglet_1
            {
                    background:#ffffff;
                    border-bottom:0px solid black;
                    padding-bottom:4px;
            }
            .contenu_onglet
            {
                    background-color:#ffffff;
                    border:1px solid black;
                    margin-top:-1px;
                    padding:5px;
                    display:none;
            }
            ul
            {
                    margin-top:0px;
                    margin-bottom:0px;
                    margin-left:-10px
            }
            h1
            {
                    margin:0px;
                    padding:0px;
            }
        </style>
     
    	<div  class="systeme_onglets">
            <div id="submenu" class="onglets">
                <span class="onglet_0 onglet" id="onglet_quoi" onclick="javascript:change_onglet('quoi');">Importer</span>
                <span class="onglet_0 onglet" id="onglet_qui" onclick="javascript:change_onglet('qui');">Exporter</span>
    			<div class="clear"></div>
            </div>
            <div id="content" class="contenu_onglets">
                <div class="contenu_onglet" id="contenu_onglet_quoi">
     
    				<h3>Importer :</h3>
    				<form action="./admin.php" method="get">
    					<input type="file" name="fichier" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    					<input type="submit" name="action" value="Importer" />
    				</form>
     
    				<div class="clear"></div>
    			</div>
    		<div class="contenu_onglet" id="contenu_onglet_qui">
    			<h3>Exporter</h3>
    			La liste des élèves :
    			<form action="./admin.php" method="get">
    				<input type="submit" name="action" value="Exporter Eleve" />
    			</form>
    			La liste MEF :
    			<form action="./admin.php" method="get">
    				<input type="submit" name="action" value="Exporter MEF" />
    			</form>
    		</div>
     
    		</div>
    	</div>
     
    	<script type="text/javascript">
            //<!--
                    var anc_onglet = 'quoi';
                    change_onglet(anc_onglet);
            //-->
            </script>
     
    </body>
    </html>

  7. #7
    Modérateur
    Avatar de Kreepz
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2011
    Messages
    681
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Distribution

    Informations forums :
    Inscription : Juin 2011
    Messages : 681
    Points : 1 458
    Points
    1 458
    Billets dans le blog
    1
    Par défaut
    Bonjour,

    Pourrais t'on voir le fichier admin.php ?
    Pensez à regarder nos cours et tutoriels PHP ainsi que notre FAQ PHP avant de poser votre question!
    Un message vous a aidé, n'oubliez pas le

  8. #8
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut
    Voila

    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
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    <?php
    session_start();
    include_once('classes/Eleve.class.php');
    include_once('classes/Prof.class.php');
    include_once('classes/Examen.class.php');
    include_once('classes/Matiere.class.php');
     
    $action = isset($_GET['action'])? $_GET['action'] : $_GET['action'] = "";
     
        switch( $action ){
            case "Ajouter":
            	addEleve();
            	break;
            case "supprEleve":
                deleteEleve();
                break;
            case "Inscrire" :
                subEleve();
                break;
            case "Rajouter":
            	addProf();
            	break;
            case "supprProf":
                deleteProf();
                break;
            case "ReInscrire" :
                subProf();
                break;
            case "listeExam":
                listeExam();
                break;
            case "Créer":
                addExam();
                break;
            case "deleteExam":
                deleteExam();
                break;
            case "import":
                affImport();
            case "Importer":
                importXls();
                break;
            case "Exporter Eleve":
                exportXls();
                break;
            case "Exporter MEF":
                exportXlsMEF();
                break;
            case "Associer":
                addJury();
                break;
            default:
            	header('Location: login.php');
        }
     
     
        //Gestion d'un élève : 3 fonctions
        function addEleve(){
            if( !empty($_GET['nom']) && !empty($_GET['prenom1']) && !empty($_GET['classeEl']) && !empty($_GET['ine']) && !empty($_GET['sexe']) && !empty($_GET['lv1'])){
     
                if(strlen($_GET['ine']) != 11 || is_numeric($_GET['ine'][10])){
                    header('Location: index.php?action=listeEleve&err=ine');
                    exit();
                }
     
                for($i = 0; $i <10; $i++){
                    if(!is_numeric($_GET['ine'][$i])){
                        header('Location: index.php?action=listeEleve&err=ine');
                        exit();
                    }
                }
     
                if($_GET['sexe'] != "M" && $_GET['sexe'] != "F"){
                    header('Location: index.php?action=listeEleve&err=sexe');
                    exit();
                }
     
                if(!verifDate($_GET['naissance'])){
                    header('Location: index.php?action=listeEleve&err=date');
                    exit();
                }
     
                if(($_GET['lv1'] == "AGL1" && $_GET['lv2'] == "AGL1") || ($_GET['lv1'] == "AGL1" && $_GET['lv2'] == "AGL2")){
                    header('Location: index.php?action=listeEleve&err=langue');
                    exit();
                }
     
                if(($_GET['lv1'] == "ALL1" && $_GET['lv2'] == "ALL1") || ($_GET['lv1'] == "ALL1" && $_GET['lv2'] == "ALL2")){
                    header('Location: index.php?action=listeEleve&err=langue');
                    exit();
                }
     
                $date = convertirDateAnglaisVersFrancais($_GET['naissance']);
                $nom = $_GET['nom'];
                $prenom1 = $_GET['prenom1'];
                $prenom2= $_GET['prenom2'];
                $classe = $_GET['classeEl'];
                $prenom3 = $_GET['prenom3'];
                $ine = $_GET['ine'];
                $sexe = $_GET['sexe'];
                $lv1 = $_GET['lv1'];
                $lv2 = $_GET['lv2'];
                $option = $_GET['option'];
                $mef = verifMEF($lv1, $lv2, $classe);
     
                if($option == "Aucun"){
                    $option = null;
                }
                if($lv2 == "Aucun"){
                    $lv2 = null;
                }
                $eleve = new Eleve();
        		$eleve->setData( $ine, $nom, $prenom1, $classe, $sexe);
        		$eleve->setClasse($classe, $lv1, $lv2, $option, $mef);
                $eleve->setPrename( $prenom2, $prenom3);
                $eleve->setDate($date);
     
        		$eleve->registerEleve();
        		header('Location: index.php?action=listeEleve&err=ok');
            }
            else{
                header('Location: index.php?action=listeEleve&err=champ');
            }
    	}
     
        function verifDate($date){
            $verifDate = explode('/' , $date);
     
                if(checkdate($verifDate[1], $verifDate[0], $verifDate[2])){
                    return true;
                }
                else{
                return false;
                }
     
        }
     
        function verifMEF($lv1, $lv2, $classe){
            if(($lv1 == "AGL1" && $lv2 == "Aucun") || ($lv1 == "AGL1" && $lv2 == "ALL2") || ($lv1 == "AGL1" && $lv2 == "ESP2") || ($lv1 == "ALL1" && $lv2 == "AGL2")){
                $mef = $classe[0].'EME';
            }
            elseif($lv1 == "AGL1" && $lv2 == "ALL1"){
                $mef = $classe[0].'EME BILINGUE TRILINGUE';
            }
            elseif($lv1 == "ALL1" && $lv2 == "AGL1"){
                $mef = $classe[0].'EME TRILINGUE';
            }
            else{
                $mef = 'NA';
            }
            return $mef;
        }
     
        function convertirDateAnglaisVersFrancais($date){
             $tabDate = explode('/' , $date);
             $enDate  = $tabDate[2].'-'.$tabDate[1].'-'.$tabDate[0];
             return $enDate;
        }
     
    	function deleteEleve(){
    	    if(!empty($_GET['id'])){
                $id = $_GET['id'];      
                $eleve = new Eleve();
                $eleve->deleteEleve($id);
                header('Location: index.php?action=listeEleve&err=delok');
    	    }
    	    else{
    	        header('Location: index.php?action=listeEleve&err=delpro');
    	    }
        }
     
        function subEleve(){
            if(!empty($_GET['eleveCoche']) && !empty($_GET['examen']) && $_GET['examen'] != 'Aucun'){
                $eleve = new Eleve();
                $examen = new Examen();
                $idexam = $examen->getIdExam($_GET['examen']);
                $eleve->inscriptionEleve($idexam, $_GET['eleveCoche']);
                header('Location: index.php?action=listeEleve&err=ok');
            }
            else{
                header('Location: index.php?action=listeEleve&err=check');
            }
        }
     
        // Gestion d'un examen : 3 fonctions
        function addExam(){
     
            if(isset($_GET['libelleExam']) && isset($_GET['dureePass']) && $_GET['libelleExam'] != "" && $_GET['dureePass'] != ""){
     
                $examen = new Examen();
                $matiere = new Matiere();
     
                $libelleExam = $_GET['libelleExam'];
                $dureePass = $_GET['dureePass'];
                $id = $matiere->getIdMatiere($_GET['matiere']);
     
                $examen->setData($dureePass, $libelleExam, $id);
                $examen->insertExam();
                header('Location: admin.php?action=listeExam');
            }
            else{
                header('Location: admin.php?action=listeExam');
            }
        }
     
        function listeExam(){
            $examen = new Examen();
            $matiere = new Matiere();
     
            $listeMatiere = $matiere->getMatiere();
            $listeExam = $examen->getExamen();
            require ('view/newExam.php');
        }
     
        function deleteExam(){
     
            $idExam = $_GET['idExam'];
            $examen = new Examen();
            $examen->deleteExamen($idExam);
            header('Location: admin.php?action=listeExam');
        }
     
        // Gestion des professeurs : 3 fonctions
        function addProf(){
            if( isset($_GET['nom']) && isset($_GET['prenom'])){
     
                $prof = new Professeur();
                $matiere = new Matiere();
     
                $id = $matiere->getIdMatiere($_GET['matiere']);
                $nom = $_GET['nom'];
                $prenom = $_GET['prenom'];
        		$prof->setProf( $id, $nom, $prenom);
     
        		$prof->registerProf();
        		header('Location: index.php?action=listeProf');
            }
            else{
                header('Location: view/listeProf.php');
            }
     
    	}
     
    	function DeleteProf(){
            $id = $_GET['id'];      
            $prof = new Professeur();
            $prof->deleteProf($id);
            header('Location: index.php?action=listeProf');
        }
     
        function subProf(){
            $prof = new Professeur();
            $prof->inscriptionProf($_GET['jury'], $_GET['profCoche']);
        }
     
        function affImport(){
            require('view/import.php');
        }
     
        function importXls(){
     
            $eleve = new Eleve();
            try{
        		require 'classes/coBDD.php';
        		require 'classes/PHPExcel.php';
     
        		// Chargement du fichier Excel
        		require_once 'classes/PHPExcel/IOFactory.php';
     
        		$objectReader = PHPExcel_IOFactory::createReader('Excel2007');
            	$objectReader->setReadDataOnly(true);
     
        		$inputFileType = PHPExcel_IOFactory::identify('ElevesComplete.xlsx');
     
        		$objectReader = PHPExcel_IOFactory::createReader($inputFileType);
            	$objectReader->setReadDataOnly(true);
     
        		$objPHPExcel = $objectReader->load($_GET['fichier']); 
            	$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
     
    		}catch (Exception $e){
    			die('Erreur : ' . $e->getMessage());
    		}
            //$eleve->registerCSV($_GET['fichier']);
            //$message = '<p style="color: green;">Le fichier a bien été enregistré dans la base de données.</p>';
            require('view/import.php');
     
        }
     
     
     
        //WIP
        function addJury(){
            $prof = new Professeur();
     
            $idprof1 = explode(' ', $_GET['prof1']);
            $idprof2 = explode(' ', $_GET['prof2']);
            $idprof1 = implode('', $idprof1);
            $idprof2 = implode('', $idprof2);
    		$salle = $_GET['salle'];
    		$horaire = $_GET['horaire'];
    		$prof -> setJury($idprof1, $idprof2, $salle, $horaire);
     
            require('view/gestJury.php');
        }
     
        function exportXls(){
            $eleve = new Eleve();
            $eleve->setXls();
            affImport();
        }
     
        function exportXlsMEF(){
            $eleve = new Eleve();
            $eleve->setXlsMEF();
            affImport();
        }
    ?>

  9. #9
    Membre habitué
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2015
    Messages
    107
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Vendée (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Février 2015
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Salut,

    Au risque de dire une bêtise, je dirai que le problème vient du fait que $_GET["fichier"] est appelé dans une fonction, dans laquelle le $_GET n'existe pas, ou plutôt, n'est pas celui envoyé par ton formulaire.

    Si c'est bien ça, il faut que tu passes ton fichier ($_GET["fichier"]) en paramètre de ta fonction importXls().
    Darkauron

  10. #10
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut
    Merci beaucoup, c'était ça !

  11. #11
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut
    Euh ok, y a une erreur qui est apparue, j'ai rien modifié d'autre et j'ai reçu Fatal error Cannon re-assign auto_global variable _ GET in C:\wamp\www\workspace\admin.php on line 260 alors qu'avant y avait pas de problème? wut?

    function importXls($_GET['fichier']) {

  12. #12
    Membre habitué
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2015
    Messages
    107
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Vendée (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Février 2015
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Dans la définition de ta fonction (function importXls) tu ne dois pas mettre $_GET["fichier"], tu dois mettre le nom d'une variable (oui, $fichier est une bonne idée).

    Par contre, c'est dans l'appel de ta fonction (ligne 40 environ) que tu peux mettre $_GET["fichier"] en paramètre, le mieux étant peut être de passé par une variable entre la récupération du GET et l'appel de la fonction.
    Darkauron

  13. #13
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut
    Undefined index fichier in (...) on line 41
    haha j'en peux plus xD j'ai essayé comme tu as dit, même en passant par une variable entre la récupération du GET et l'appel de la fonction.

  14. #14
    Membre habitué
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2015
    Messages
    107
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Vendée (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Février 2015
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Tu peux poster le nouveau code stp ?
    Darkauron

  15. #15
    Candidat au Club
    Homme Profil pro
    Etudiant
    Inscrit en
    Mars 2015
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Etudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 20
    Points : 3
    Points
    3
    Par défaut
    Ah non excuse moi, j'avais oublié un break; y aplus derreur pour l'instant

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Conseil] Import de fichier CSV vers MySQL
    Par ShinJava dans le forum JDBC
    Réponses: 6
    Dernier message: 15/03/2005, 19h14
  2. Connexion depuis LAN impossible vers Mysql sur RH8
    Par RamDevTeam dans le forum Administration
    Réponses: 4
    Dernier message: 10/02/2005, 15h28
  3. [FileUpload] Fichier vers MySql
    Par Kimael dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 30/06/2004, 16h18
  4. Transefert de données de DBASE IV vers Mysql
    Par sessime dans le forum Bases de données
    Réponses: 2
    Dernier message: 04/03/2004, 09h43
  5. Export base Access vers MySql
    Par jjn1er dans le forum Outils
    Réponses: 7
    Dernier message: 10/03/2003, 23h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo