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 :

Faire une exportation de ma base de données à partir d'une requête


Sujet :

Langage PHP

  1. #21
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    Euh je me suis planté, de A1 à M1 j'ai fait Nom, Prénom, etc et de A2 à M2 j'ai fait les ligneresultat.

    Comment ça crée un fichier de ce nom ? je crée un classeur excel ayant deja les entête de colonne ?
    Et c'est quoi ce $rowIndex=1 ?

  2. #22
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    Citation Envoyé par renaud22 Voir le message
    Euh je me suis planté, de A1 à M1 j'ai fait Nom, Prénom, etc et de A2 à M2 j'ai fait les ligneresultat.

    Comment ça crée un fichier de ce nom ? je crée un classeur excel ayant deja les entête de colonne ?
    Et c'est quoi ce $rowIndex=1 ?
    Pour le 'Euh je me suis planté' c pas grâve j'ai changé de méthode

    De mon côté, j'ai jamais fais sur le navigateur (en fichier seulement) alors c nouveau et je test avec toi

    Sérieux, oui tu crées un fichier avec une ligne d'entêtes

    $rowIndex c'est pour la méthode setCellValueByColumnAndRow qui écrit dans la cellule de colonne Column et de ligne Row (elle est bien cette méthode, non !)

  3. #23
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    Voilà je viens de faire ce que tu m'as conseillé

    Mais le problème c'est que quand j'exécute, quandle classeur Excel s'ouvre, j'ai toujours droit au message :

    Impossible d'ouvrir le fichier "exportationphp.xslx" car son format ou son extension n'est pas valide. Vérifiez que le fichier n'est pas endommagé et que son extension correspond bien au format du fichier.

  4. #24
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    Bon, au lieu de passer par le navigateur, crées le fichier dans un répertoire et nous verrons déjà si c bon.

  5. #25
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    Comment ça crée le fichier dans un répertoire ?

  6. #26
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    P.... je viens de voir l'erreur:

    Ta citation
    Impossible d'ouvrir le fichier "exportationphp.xslx" car son format ou son extension n'est pas valide. Vérifiez que le fichier n'est pas endommagé et que son extension correspond bien au format du fichier.
    MAIS l'extension .xslx ça existe PAS C'EST .xlsx

    Bon sinon, ça marche très bien chez moi, dans le navigateur, ça t'ouvre une fenêtre te demandant le fichier ....xlsx et voilà c cool

  7. #27
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    Désolé c'est moi qui ai fait une faute de frappe
    Le message me dis bien xlsx

  8. #28
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    Tu peux ouvrir ce type de fichier avec Excell ?

    Tu as quoi comme Excell: 2003 ou 2007 ?

  9. #29
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    J'ai le 2007

  10. #30
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    Et le navigateur ?

    Donc tu peux ouvrir un fichier de ce type ?

  11. #31
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    Là le navigateur c'est firefox. Bah oui j'en ouvre tout le temps des fichiers en xlsx, c'est pour ça que là je vois pas pourquoi il veut pas le seul problème que je peux imaginer là c'est que j'ai pas extrait tout ce qu'il fallait de la librairie PHPExcel.

  12. #32
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    Le seul problème que je peux imaginer là c'est que j'ai pas extrait tout ce qu'il fallait de la librairie PHPExcel.
    Pour l'install, tu as juste à copier le répertoire Classes chez toi et c'est tout !

    Pour info, j'ai firefox, Excell 2007 et ça marche nickel

  13. #33
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    Parce que moi quand j'ai extrait le repertoire classe ça me disait qu'il y avait des trucs inexistant alors du coup j'ai mis dans le dossier www :
    -Le dossier Classes
    -Le dossier PHPExcel
    -Le PHPExcel.php
    -Et le dossier PHPExcel-1.7.7 zipé et dézipé

    Tout ce que j'ai sortie de classes je l'ai juste copier coller dans le dossier www, donc c'est toujours aussi dans Classes au pire des cas.

  14. #34
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    Donnes moi ton dernier code en cours (tu peux m'éviter les 20 30 lignes de code html pour le tableau à 2 colonnes) ... j'ai peut être pas vu qqchose.

    Et sinon, tu peux qd même essayer les qq lignes suivantes (ce sont celles que j'ai testé et qui sont dans le tuto)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    include 'Classes/PHPExcel.php';
    include 'Classes/PHPExcel/Writer/Excel2007.php';
     
    $workbook = new PHPExcel;
     
    $sheet = $workbook->getActiveSheet();
    $sheet->setCellValue('A1','MaitrePylos');
     
    $writer = new PHPExcel_Writer_Excel2007($workbook);
     
     header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition:inline;filename=Fichier.xls ');
     $writer->save('php://output');

  15. #35
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    Bon point rassurant, le bout de code du tuto il marche

    Mon code actuel en abrégé :

    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
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    <html>
    <?php
     
    include 'PHPExcel.php';
    include 'PHPExcel/Writer/Excel2007.php';
     
     
    $workbook = new PHPExcel;
    $sheet = $workbook->getActiveSheet();
     
     
    $connection=mysql_connect("localhost", "root", "") or die ("message d'erreur".mysql_error($connection));
    $base=("test");
     
    if(!$connection)
    	die("connection impossible");
     
    	$mabasededonnee=$base;
    	mysql_select_db($mabasededonnee) or die ("pas de connection");
    	$formchoix=$_POST["formchoix"];
    	$formselection=$_POST["formselection"];
    	$formaffichage=$_POST["formaffichage"];
     
    	if($formchoix=="1")
    	{
     
    		echo "<table border=1 width=550 height=80 align=center bgcolor=#BCBCBC>";
    		echo "<tr height 20>";
    		echo "<td align=center>"."<b>"."Veuillez faire un choix"."</b>"."</td>";
    		echo "</tr>";
    		echo "<tr height 20>";
    		echo "<td align=center>"."<a href='javascript:history.back()'>Retour</a>"."</td>";
    		echo "</tr>";
    		echo "</table>";
     
     
    	}
    	else
    	{
    		if($formchoix=="2")
    		{	
     
     
    			if($formaffichage=="1")
    			{
    				$requete="select nom, prenom, tel, fax, mobile, mail, lieudetravail, adresse, fonction, machine.codemachine, codepostal, ville, site from employe, machine, jointure where employe.codee=jointure.codee and jointure.codemachine=machine.codemachine and employe.codee='$formselection' group by machine.codemachine;";
    				$resultat=mysql_query($requete);
     
     
     
    				if (mysql_num_rows($resultat) == 0) 
    				{
    					echo "<table border=1 width=550 height=80 align=center bgcolor=#BCBCBC>";
    					echo "<tr height 20>";
    					echo "<td align=center>"."<b>"."Aucun enregistrement ne correspond"."</b>"."</td>";
    					echo "</tr>";
    					echo "</table>";
    				} 
    				else
    				{
     
    					while ($ligneresultat = mysql_fetch_array($resultat))
    					{
     
    						if($ligneresultatbis=mysql_fetch_array($resultat))
    						{
     
    							echo "<table border=1 width=600 height=80 align=left bgcolor=#BCBCBC>";
    							echo "<tr height=20>";
    							echo "<td>"."Nom"."</td>";
    							...
     
     
    							echo "<table border=1 width=600 height=80 align=right bgcolor=#BCBCBC>";
    							echo "<tr height=20>";
    							echo "<td>"."Nom"."</td>";
    							...
    							echo "</table>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>";
     
    						}
    						else
    						{
    							echo "<table border=1 width=600 height=80 align=center bgcolor=#BCBCBC>";
    							echo "<tr height=20>";
    							echo "<td>"."Nom"."</td>";
    							...
    						}
     
    					}
     
     
    				}
     
    				echo "<br>"."<table border=1 width=150 height=80 align=center bgcolor=#BCBCBC>";
    				echo "<tr height 20>";
    				echo "<td align=center>"."<a href='javascript:history.back()'>Retour</a>"."</td>";
    				echo "</tr>";
    				echo "</table>"."<br>"."<br>";
     
    			}
    			else
    			{
    				$requete="select nom, prenom, tel, fax, mobile, mail, lieudetravail, adresse, fonction, machine.codemachine, codepostal, ville, site from employe, machine, jointure where employe.codee=jointure.codee and jointure.codemachine=machine.codemachine and employe.codee='$formselection' group by machine.codemachine;";
    				$resultat=mysql_query($requete);
    				$rowIndex=2;
     
     
    					$sheet->setCellValueByColumnAndRow(1, 1, 'Nom');
    					$sheet->setCellValueByColumnAndRow(2, 1, 'Prenom');
    					$sheet->setCellValueByColumnAndRow(3, 1, 'Telephone');
    					$sheet->setCellValueByColumnAndRow(4, 1, 'fax');
    					$sheet->setCellValueByColumnAndRow(5, 1, 'Mobile');
    					$sheet->setCellValueByColumnAndRow(6, 1, 'E-mail');
    					$sheet->setCellValueByColumnAndRow(7, 1, 'Lieu de travail');
    					$sheet->setCellValueByColumnAndRow(8, 1, 'Adresse physique');
    					$sheet->setCellValueByColumnAndRow(9, 1, 'Fonction');
    					$sheet->setCellValueByColumnAndRow(10, 1, 'Code machine');
    					$sheet->setCellValueByColumnAndRow(11, 1, 'Code postal');
    					$sheet->setCellValueByColumnAndRow(12, 1, 'Ville');
    					$sheet->setCellValueByColumnAndRow(13, 1, 'Site');
     
     
                  		  		while ($ligneresultat = mysql_fetch_array($resultat))
                   		  		{
     
                       		 	    	$sheet->setCellValueByColumnAndRow(1, $rowIndex, $ligneresultat['nom']);
                           				$sheet->setCellValueByColumnAndRow(2, $rowIndex, $ligneresultat['prenom']);
                        		  		$sheet->setCellValueByColumnAndRow(3, $rowIndex, $ligneresultat['tel']);
                        		    		$sheet->setCellValueByColumnAndRow(4, $rowIndex, $ligneresultat['fax']);
                        		    		$sheet->setCellValueByColumnAndRow(5, $rowIndex, $ligneresultat['mobile']);
                        		    		$sheet->setCellValueByColumnAndRow(6, $rowIndex, $ligneresultat['mail']);
                        		    		$sheet->setCellValueByColumnAndRow(7, $rowIndex, $ligneresultat['lieudetravail']);
                        		    		$sheet->setCellValueByColumnAndRow(8, $rowIndex, $ligneresultat['adresse']);
                        		    		$sheet->setCellValueByColumnAndRow(9, $rowIndex, $ligneresultat['fonction']);
                        		    		$sheet->setCellValueByColumnAndRow(10, $rowIndex, $ligneresultat['codemachine']);
                        		    		$sheet->setCellValueByColumnAndRow(11, $rowIndex, $ligneresultat['codepostal']);
                         		   		$sheet->setCellValueByColumnAndRow(12, $rowIndex, $ligneresultat['ville']);
                         		   		$sheet->setCellValueByColumnAndRow(13, $rowIndex, $ligneresultat['site']);
    						$rowIndex++;
     
     
    					}	
     
     
    					$writer = new PHPExcel_Writer_Excel2007($workbook);
    					$writer->setOffice2003Compatibility(true);
     
                           			header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                           	 		header('Content-Disposition:inline;filename=exportationphp.xlsx ');
                           	 		$writer->save('php://output');
     
     
     
     
     
    			}
     
     
     
    		}
    		else
    		{
    			if($formchoix=="3")
    			{
     
    				if($formaffichage=="1")
    				{
     
    					$requete="select machine.codemachine, marque, modele, numerodeserie, affectation, service, datefingarantie, codepostal, ville, site, employe.codee, nom, prenom, tel, fax, mobile, mail, lieudetravail, adresse, fonction from employe, machine, jointure where employe.codee=jointure.codee and jointure.codemachine=machine.codemachine and machine.codemachine='$formselection';";
    					$resultat=mysql_query($requete);
    					$ligneresultat=mysql_fetch_array($resultat);
     
    					if(!$ligneresultat)
    					{
    						echo "<table border=1 width=550 height=80 align=center bgcolor=#BCBCBC>";
    						echo "<tr height 20>";
    						echo "<td align=center>"."<b>"."Aucun enregistrement ne correspond"."</b>"."</td>";
    						echo "</tr>";
    						echo "</table>";
     
    					}
    					else
    					{
     
    						echo "<table border=1 width=600 height=80 align=center bgcolor=#BCBCBC>";
    						echo "<tr height=20>";
    						echo "<td>"."Code machine"."</td>";
    						echo "<td>".$ligneresultat['codemachine']."</td>";
    						echo "</tr>";
    						...
     
     
     
    					}
    					echo "<br>"."<table border=1 width=150 height=80 align=center bgcolor=#BCBCBC>";
    					echo "<tr height 20>";
    					echo "<td align=center>"."<a href='javascript:history.back()'>Retour</a>"."</td>";
    					echo "</tr>";
    					echo "</table>";
     
    				}
    				else
    				{
     
    					$requete="select machine.codemachine, marque, modele, numerodeserie, affectation, service, datefingarantie, codepostal, ville, site, employe.codee, nom, prenom, tel, fax, mobile, mail, lieudetravail, adresse, fonction from employe, machine, jointure where employe.codee=jointure.codee and jointure.codemachine=machine.codemachine and machine.codemachine='$formselection';";
    					$resultat=mysql_query($requete);
    					$ligneresultat=mysql_fetch_array($resultat);
     
     
    					if(!$ligneresultat)
    					{
    						echo "<table border=1 width=550 height=80 align=center bgcolor=#BCBCBC>";
    						echo "<tr height 20>";
    						echo "<td align=center>"."<b>"."Aucun enregistrement ne correspond"."</b>"."</td>";
    						echo "</tr>";
    						echo "</table>";
    						echo "<br>"."<table border=1 width=150 height=80 align=center bgcolor=#BCBCBC>";
    						echo "<tr height 20>";
    						echo "<td align=center>"."<a href='javascript:history.back()'>Retour</a>"."</td>";
    						echo "</tr>";
    						echo "</table>";
    					}
    					else
    					{
     
    						$sheet->setCellValue('A1', 'Code machine');
    						$sheet->setCellValue('A2', 'Marque');
    						$sheet->setCellValue('A3', 'Modele');
    						$sheet->setCellValue('A4', 'Numero de serie');
    						$sheet->setCellValue('A5', 'Affectation');
    						$sheet->setCellValue('A6', 'Service');
    						$sheet->setCellValue('A7', 'Date de fin de garantie');
    						$sheet->setCellValue('A8', 'Code postal');
    						$sheet->setCellValue('A9', 'Ville');
    						$sheet->setCellValue('A10', 'Site');
    						$sheet->setCellValue('A11', 'Code employe');
    						$sheet->setCellValue('A12', 'Nom');
    						$sheet->setCellValue('A13', 'Prenom');
    						$sheet->setCellValue('A14', 'Telephone');
    						$sheet->setCellValue('A15', 'Fax');
    						$sheet->setCellValue('A16', 'Mobile');
    						$sheet->setCellValue('A17', 'lieu de travail');
    						$sheet->setCellValue('A18', 'Adresse physique');
    						$sheet->setCellValue('A19', 'Fonction');
    						$sheet->setCellValue('B1', $ligneresultat['codemachine']);
    						$sheet->setCellValue('B2', $ligneresultat['marque']);
    						$sheet->setCellValue('B3', $ligneresultat['modele']);
    						$sheet->setCellValue('B4', $ligneresultat['numerodeserie']);
    						$sheet->setCellValue('B5', $ligneresultat['affectation']);
    						$sheet->setCellValue('B6', $ligneresultat['service']);
    						$sheet->setCellValue('B7', $ligneresultat['datefingarantie']);
    						$sheet->setCellValue('B8', $ligneresultat['codepostal']);
    						$sheet->setCellValue('B9', $ligneresultat['ville']);
    						$sheet->setCellValue('B10', $ligneresultat['site']);
    						$sheet->setCellValue('B11', $ligneresultat['codee']);
    						$sheet->setCellValue('B12', $ligneresultat['nom']);
    						$sheet->setCellValue('B13', $ligneresultat['prenom']);
    						$sheet->setCellValue('B14', $ligneresultat['tel']);
    						$sheet->setCellValue('B15', $ligneresultat['fax']);
    						$sheet->setCellValue('B16', $ligneresultat['mobile']);
    						$sheet->setCellValue('B17', $ligneresultat['lieudetravail']);
    						$sheet->setCellValue('B18', $ligneresultat['adresse']);
    						$sheet->setCellValue('B19', $ligneresultat['fonction']);
     
     
    						$writer = new PHPExcel_Writer_Excel2007($workbook);
    						$writer->setOffice2003Compatibility(true);
     
                           				header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                           	 			header('Content-Disposition:inline;filename=exportationphp.xlsx ');
                           	 			$writer->save('php://output');
     
    					}
     
    				}
     
     
    			}
    			else
    			{
     
     
    				$requete1="select codemachine from machine where machine.codemachine='$formselection';";
    				$resultat1=mysql_query($requete1);
    				$requete2="select codemachine from nonreconcilies where nonreconcilies.codemachine='$formselection';";
    				$resultat2=mysql_query($requete2);
    				$requete3="select codemachine from retourstock where retourstock.codemachine='$formselection';";
    				$resultat3=mysql_query($requete3);
    				$requete4="select weblogin.codee from weblogin, employe, jointure, machine, webpdn where weblogin.codee=employe.codee and employe.codee=jointure.codee and jointure.codemachine=machine.codemachine and webpdn.codemachine=machine.codemachine and machine.codemachine='$formselection' and weblogin.serveur=webpdn.serveur;";
    				$resultat4=mysql_query($requete4);
     
     
    					if(mysql_num_rows($resultat1) == 0)
    					{
    						echo "<table border=1 width=550 height=80 align=left bgcolor=#BCBCBC>";
    						echo "<caption>"."Table GP"."</caption>";
    						echo "<tr height 20>";
    						echo "<td align=center>"."<b>"."Aucun enregistrement ne correspond"."</b>"."</td>";
    						echo "</tr>";
    						echo "</table>";
    					}
    					else
    					{
     
    						$requete="select jointure.codemachine, employe.codee, nom, prenom, tel, mobile from employe, jointure where employe.codee=jointure.codee and jointure.codemachine='$formselection';";
    						$resultat=mysql_query($requete);
    						$ligneresultat=mysql_fetch_array($resultat);
     
     
    						echo "<table border=1 width=550 height=80 align=left bgcolor=#BCBCBC>";
    						echo "<caption>"."Table GP"."</caption>";
    						echo "<tr height=20>";
    						echo "<td>"."Code machine"."</td>";
    						echo "<td>".$ligneresultat['codemachine']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Code employe"."</td>";
    						echo "<td>".$ligneresultat['codee']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Nom"."</td>";
    						echo "<td>".$ligneresultat['nom']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Prénom"."</td>";
    						echo "<td>".$ligneresultat['prenom']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Téléphone"."</td>";
    						echo "<td>".$ligneresultat['tel']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Mobile"."</td>";
    						echo "<td>".$ligneresultat['mobile']."</td>";
    						echo "</tr>";
    						echo "</table>";		
     
    					}
     
     
    					if(mysql_num_rows($resultat2) == 0)
    					{
    						echo "<table border=1 width=550 height=80 align=right bgcolor=#BCBCBC>";
    						echo "<caption>"."Table nonreconcilies"."</caption>";
    						echo "<tr height 20>";
    						echo "<td align=center>"."<b>"."Aucun enregistrement ne correspond"."</b>"."</td>";
    						echo "</tr>";
    						echo "</table>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>";
    					}
    					else
    					{
     
    						$requete="select nonreconcilies.codemachine, employe.codee, nom, prenom, tel, mobile from employe, jointure, machine, nonreconcilies where employe.nni=jointure.codee and jointure.codemachine=machine.codemachine and machine.codemachine=nonreconcilies.codemachine and nonreconcilies.codemachine='$formselection';";
    						$resultat=mysql_query($requete);
    						$ligneresultat=mysql_fetch_array($resultat);
     
     
    						echo "<table border=1 width=550 height=80 align=right bgcolor=#BCBCBC>";
    						echo "<caption>"."Table nonreconcilies"."</caption>";
    						echo "<tr height=20>";
    						echo "<td>"."Code machine"."</td>";
    						echo "<td>".$ligneresultat['codemachine']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Code employe"."</td>";
    						echo "<td>".$ligneresultat['codee']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Nom"."</td>";
    						echo "<td>".$ligneresultat['nom']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Prénom"."</td>";
    						echo "<td>".$ligneresultat['prenom']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Téléphone"."</td>";
    						echo "<td>".$ligneresultat['tel']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Mobile"."</td>";
    						echo "<td>".$ligneresultat['mobile']."</td>";
    						echo "</tr>";
    						echo "</table>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>"."<br>";		
     
    					}
     
    					if(mysql_num_rows($resultat3) == 0)
    					{
    						echo "<table border=1 width=550 height=80 align=left bgcolor=#BCBCBC>";
    						echo "<caption>"."Table retourstock"."</caption>";
    						echo "<tr height 20>";
    						echo "<td align=center>"."<b>"."Aucun enregistrement ne correspond"."</b>"."</td>";
    						echo "</tr>";
    						echo "</table>";
    					}
    					else
    					{
     
    						$requete="select retourstock.codemachine, employe.codee, nom, prenom, tel, mobile from employe, jointure, machine, retourstock where employe.codee=jointure.codee and jointure.codemachine=machine.codemachine and machine.codemachine=retourstock.codemachine and retourstock.codemachine='$formselection';";
    						$resultat=mysql_query($requete);
    						$ligneresultat=mysql_fetch_array($resultat);
     
     
    						echo "<table border=1 width=550 height=80 align=left bgcolor=#BCBCBC>";
    						echo "<caption>"."Table retourstock"."</caption>";
    						echo "<tr height=20>";
    						echo "<td>"."Code machine"."</td>";
    						echo "<td>".$ligneresultat['codemachine']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Code employe"."</td>";
    						echo "<td>".$ligneresultat['codee']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Nom"."</td>";
    						echo "<td>".$ligneresultat['nom']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Prénom"."</td>";
    						echo "<td>".$ligneresultat['prenom']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Téléphone"."</td>";
    						echo "<td>".$ligneresultat['tel']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Mobile"."</td>";
    						echo "<td>".$ligneresultat['mobile']."</td>";
    						echo "</tr>";
    						echo "</table>";		
     
    					}
     
     
     
    					if(mysql_num_rows($resultat4) == 0)
    					{
    						echo "<table border=1 width=550 height=80 align=right bgcolor=#BCBCBC>";
    						echo "<caption>"."Table webai"."</caption>";
    						echo "<tr height 20>";
    						echo "<td align=center>"."<b>"."Aucun enregistrement ne correspond"."</b>"."</td>";
    						echo "</tr>";
    						echo "</table>";
    					}
    					else
    					{
     
    						$requete="select webpdn.codemachine, employe.codee, nom, prenom, tel, mobile from  employe, jointure, machine, webpdn where employe.codee=jointure.codee and jointure.codemachine=machine.codemachine and machine.codemachine=webpdn.codemachine and webpdn.codemachine='$formselection';";
    						$resultat=mysql_query($requete);
    						$ligneresultat=mysql_fetch_array($resultat);
     
    						$requetepdn="select description from webpdn where codemachine='$formselection';";
    						$resultatpdn=mysql_query($requetepdn);
    						$lignepdn=mysql_fetch_array($resultatpdn);
     
    						$requetelogin="select description from weblogin, employe, jointure where employe.codee=jointure.codee and employe.codee=weblogin.codee and codemachine='$formselection';";
    						$resultatlogin=mysql_query($requetelogin);
    						$lignelogin=mysql_fetch_array($resultatlogin);
     
     
     
    						echo "<table border=1 width=550 height=80 align=right bgcolor=#BCBCBC>";
    						echo "<caption>"."Table web"."</caption>";
    						echo "<tr height=20>";
    						echo "<td>"."Code machine"."</td>";
    						echo "<td>".$ligneresultat['codemachine']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Description dans webpdn"."</td>";
    						echo "<td>".$lignepdn['description']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Description dans weblogin"."</td>";
    						echo "<td>".$lignelogin['description']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Code employe"."</td>";
    						echo "<td>".$ligneresultat['codee']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Nom"."</td>";
    						echo "<td>".$ligneresultat['nom']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Prénom"."</td>";
    						echo "<td>".$ligneresultat['prenom']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Téléphone"."</td>";
    						echo "<td>".$ligneresultat['tel']."</td>";
    						echo "</tr>";
    						echo "<tr height=20>";
    						echo "<td>"."Mobile"."</td>";
    						echo "<td>".$ligneresultat['mobile']."</td>";
    						echo "</tr>";	
    						echo "<caption>"."Si les 2 description ne correspondent pas, l'utilisateur de weblogin n'est pas celui a qui est attribué la machine"."</caption>";
    						echo "</table>";	
     
    					}
     
    				echo "<table border=1 width=150 height=80 align=center bgcolor=#BCBCBC>";
    				echo "<tr height 20>";
    				echo "<td align=center>"."<a href='javascript:history.back()'>Retour</a>"."</td>";
    				echo "</tr>";
    				echo "</table>";
    			}
    		}
     
    	}
     
     
     
    ?>
     
     
    </html>

  16. #36
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    Mon code actuel en abrégé :
    517 lignes, ç a c de l'abrégé

    Sinon tu devrais faire ton code en ne gardant que la partie excell (j'ai essayé chez moi et ça marche) c'est à dire juste ça:
    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
     
    				$requete="select nom, prenom, tel, fax, mobile, mail, lieudetravail, adresse, fonction, machine.codemachine, codepostal, ville, site from employe, machine, jointure where employe.codee=jointure.codee and jointure.codemachine=machine.codemachine and employe.codee='$formselection' group by machine.codemachine;";
    				$resultat=mysql_query($requete);
    				$rowIndex=2;
     
     
    					$sheet->setCellValueByColumnAndRow(1, 1, 'Nom');
    					$sheet->setCellValueByColumnAndRow(2, 1, 'Prenom');
    					$sheet->setCellValueByColumnAndRow(3, 1, 'Telephone');
    					$sheet->setCellValueByColumnAndRow(4, 1, 'fax');
    					$sheet->setCellValueByColumnAndRow(5, 1, 'Mobile');
    					$sheet->setCellValueByColumnAndRow(6, 1, 'E-mail');
    					$sheet->setCellValueByColumnAndRow(7, 1, 'Lieu de travail');
    					$sheet->setCellValueByColumnAndRow(8, 1, 'Adresse physique');
    					$sheet->setCellValueByColumnAndRow(9, 1, 'Fonction');
    					$sheet->setCellValueByColumnAndRow(10, 1, 'Code machine');
    					$sheet->setCellValueByColumnAndRow(11, 1, 'Code postal');
    					$sheet->setCellValueByColumnAndRow(12, 1, 'Ville');
    					$sheet->setCellValueByColumnAndRow(13, 1, 'Site');
     
     
                  		  		while ($ligneresultat = mysql_fetch_array($resultat))
                   		  		{
     
                       		 	    	$sheet->setCellValueByColumnAndRow(1, $rowIndex, $ligneresultat['nom']);
                           				$sheet->setCellValueByColumnAndRow(2, $rowIndex, $ligneresultat['prenom']);
                        		  		$sheet->setCellValueByColumnAndRow(3, $rowIndex, $ligneresultat['tel']);
                        		    		$sheet->setCellValueByColumnAndRow(4, $rowIndex, $ligneresultat['fax']);
                        		    		$sheet->setCellValueByColumnAndRow(5, $rowIndex, $ligneresultat['mobile']);
                        		    		$sheet->setCellValueByColumnAndRow(6, $rowIndex, $ligneresultat['mail']);
                        		    		$sheet->setCellValueByColumnAndRow(7, $rowIndex, $ligneresultat['lieudetravail']);
                        		    		$sheet->setCellValueByColumnAndRow(8, $rowIndex, $ligneresultat['adresse']);
                        		    		$sheet->setCellValueByColumnAndRow(9, $rowIndex, $ligneresultat['fonction']);
                        		    		$sheet->setCellValueByColumnAndRow(10, $rowIndex, $ligneresultat['codemachine']);
                        		    		$sheet->setCellValueByColumnAndRow(11, $rowIndex, $ligneresultat['codepostal']);
                         		   		$sheet->setCellValueByColumnAndRow(12, $rowIndex, $ligneresultat['ville']);
                         		   		$sheet->setCellValueByColumnAndRow(13, $rowIndex, $ligneresultat['site']);
    						$rowIndex++;
     
     
    					}	
     
     
    					$writer = new PHPExcel_Writer_Excel2007($workbook);
    					$writer->setOffice2003Compatibility(true);
     
                           			header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                           	 		header('Content-Disposition:inline;filename=exportationphp.xlsx ');
                           	 		$writer->save('php://output');
    ensuite tu referras au fur et à mesure tes différents cas dans les if

    je vois pas autre chose pour l'instant

  17. #37
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    mdr oui 517 lignes c'est très abrégé XD

    Donc tu pense que je devrait refaire tout le reste à coté et ne garder que ça ? Oo euh et t'en pense quoi si a la place je garde l'affichage que j'avais sans le excel, que je rajoute un bouton qui me balance sur une autre page php dans laquelle cette fois je ne met que l'ecel ?

  18. #38
    Nouveau membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Juin 2012
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2012
    Messages : 81
    Points : 36
    Points
    36
    Par défaut
    Ca y est j'ai réussi à exporter une partie sur Excel, j'ai plus qu'à faire pareil pour les autres conditions Merci beaucoup Fench tu m'as été d'une aide précieuse

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. Mettre en place une base de données à partir d'une sauvegarde
    Par snopims dans le forum MS SQL Server
    Réponses: 6
    Dernier message: 16/09/2008, 10h13
  2. Réponses: 8
    Dernier message: 14/02/2008, 18h04
  3. [C#2.0] Mettre à jour la base de données à partir d'une DataTable
    Par Rodie dans le forum Accès aux données
    Réponses: 6
    Dernier message: 16/05/2007, 14h24
  4. Réponses: 1
    Dernier message: 02/02/2007, 10h29
  5. [MySQL] Enregistrer dans une base de données à partir d'une liste déroulante
    Par snakejl dans le forum PHP & Base de données
    Réponses: 12
    Dernier message: 17/05/2006, 16h32

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