Export en Excel

Résolu/Fermé
tridam23 Messages postés 99 Date d'inscription mercredi 5 novembre 2014 Statut Membre Dernière intervention 11 juin 2021 - Modifié par tridam23 le 25/11/2014 à 14:33
tridam23 Messages postés 99 Date d'inscription mercredi 5 novembre 2014 Statut Membre Dernière intervention 11 juin 2021 - 26 nov. 2014 à 10:08
Bonjour,

j'aimerai savoir comment faire pour exporter les données en excel en frontend.
je met le code en dessous. (c'est une application pour la gestion d'inscription des élèves.

<?php
    session_start();
    if(!(isset($_SESSION['NIV'])))
        header("location:index.html");
?>
<?php
    require_once("connection.php");
    $req="select * from ELEVES";
    $rs=mysql_query($req) or die(mysql_error());
?>
<html>
<head>
    <meta charset="utf-8">
</head>
<body>
    <p><a href="saisieEleve.html"><br>
    Inscrire un élève</a>
      <body bgcolor="#FFBCBD">
      <br>
    </p>
    <p><a href="ChercherEleves.php"><br>Rechercher un élève</a></p>
    <form>
<input type="button" value="Imprimer" onClick="window.print()">
</form>
    <table border="1" width="50%">
        <tr>
            <th>CODE</th><th>PHOTO</th><th>CLASSE</th><th>NOM</th><th>PRENOM</th><th>POSTNOM</th><th>NAISSANCE</th><th>SEXE</th><th>PAYS</th><th>NATIONALITE</th><th>ADRESSE</th><th>SURNOM</th><th>RELIGION</th><th>PERE</th><th>TEL PERE</th><th>ADRESSE DOMICILE</th><th>EMAIL</th><th>EMPLOYEUR</th><th>ADRESSE EMPLOYEUR</th><th>MERE</th><th>TEL MERE</th><th>ADRESSE DOMICILE</th><th>EMAIL</th><th>EMPLOYEUR MERE</th><th>ADRESSE EMPLOYEUR MERE</th>
      </tr>
        <?php while($ET=mysql_fetch_assoc($rs)){?>
            <tr>
              <td><?php echo($ET['CODE'])?></td>
                <td><img src="images/<?php echo($ET['PHOTO'])?>" width="130" height="100" </td>
                <td><?php echo($ET['CLASSE'])?></td>
                <td><?php echo($ET['NOM'])?></td>
                <td><?php echo($ET['PRENOM'])?></td>
                <td><?php echo($ET['POSTNOM'])?></td>
                <td><?php echo($ET['NAISSANCE'])?></td>
                <td><?php echo($ET['SEXE'])?></td>
                <td><?php echo($ET['PAYS'])?></td>
                <td><?php echo($ET['NATIONALITE'])?></td>
                <td><?php echo($ET['ADRESSE'])?></td>
                <td><?php echo($ET['SURNOM'])?></td>
                <td><?php echo($ET['RELIGION'])?></td>
                <td><?php echo($ET['PERE'])?></td>
                <td><?php echo($ET['TELPERE'])?></td>
                <td><?php echo($ET['ADRESSE1'])?></td>
                <td><?php echo($ET['EMAIL'])?></td>
                <td><?php echo($ET['EMPLOYEUR'])?></td>
                <td><?php echo($ET['ADRESSEEMP'])?></td>
                <td><?php echo($ET['MERE'])?></td>
                <td><?php echo($ET['TELMERE'])?></td>
                <td><?php echo($ET['ADRESSE2'])?></td>
                <td><?php echo($ET['EMAIL2'])?></td>
                <td><?php echo($ET['EMPLOYEUR1'])?></td>
                <td><?php echo($ET['ADRESSEEMP2'])?></td>
                <?php if($_SESSION['NIV']==0){?>
                <td><a href="supprimerEleve.php?code=<?php echo($ET['CODE'])?>">Supprimer</a></td>
                <td><a href="editEleve.php?code=<?php echo($ET['CODE'])?>">Editer</a></td>
                <?php }?>
            </tr>
        <?php } ?>
</table>
</body>
</html>


1. Question : comment mettre un lien pour l'export en excel en csv ou autre
2. Question : comment à partir de ce tableau, affiche la fiche de l'élève en fonction de son code. Exemple : je clique sur l'elève 1 et sa fiche d'inscription apparaît comme un popup ou en pdf par exemple





www.tremvi.com www.bawolo.com www.biz243.com
A voir également:

2 réponses

jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 4 649
25 nov. 2014 à 14:58
Bonjour ( re.. ^^ )

1. Question : comment mettre un lien pour l'export en excel en csv ou autre


Si tu veux faire de l'export en Excel ( du vrai Excel..pas du CSV) .. il existe des class pour ça. PHPExcel par exemple.
Mais vu que tu débutes.. ça risque d'être un peu compliqué pour toi...

Donc il reste le CSV ...
Pour ça.. rien de plus "simple".
Tu créés une page php ( exporterCSV.php par exemple )
Dedans... tu écris un truc du genre :

// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv');

// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');

// output the column headings
fputcsv($output, array('Column 1', 'Column 2', 'Column 3'));

// fetch the data
 require_once("connection.php");
    $req="select * from ELEVES";
 $rs=mysql_query($req) or die(mysql_error());
// loop over the rows, outputting them
while ($row = mysql_fetch_assoc($rs)){
   fputcsv($output, $row);
}







2. Question : comment à partir de ce tableau, affiche la fiche de l'élève en fonction de son code. Exemple : je clique sur l'elève 1 et sa fiche d'inscription apparaît comme un popup ou en pdf par exemple


Tu veux parler de popup (ouverture d'une nouvelle fenetre de ton navigateur ) ou bien comme je le pense.. d'une fenêtre MODALE ?
Quoi qu'il en soit.. il te faut passer par du javascript.
Si tu veux faire une fenêtre modale.. (même si c'est réalisable en pure javascript... je t'inviterai tout de même à regarder du côté de JQUERY )
Par exemple :
https://sohtanaka.developpez.com/tutoriels/javascript/creez-fenetre-modale-avec-css-et-jquery/
0
tridam23 Messages postés 99 Date d'inscription mercredi 5 novembre 2014 Statut Membre Dernière intervention 11 juin 2021
26 nov. 2014 à 09:49
Bonjour et merci bcp jordane45 pour ton assistance
j'ai tester le phpexcel et c'est bon pour jquery je continuerai la lecture. cependant, un autre souci
<?php
require_once("connection.php");
$classe = $_POST['classe'];
$inscription = $_POST['inscription'];
$nomPhoto = $_FILES['photo']['name'];
$file_tmp_name = $_FILES['photo']['tmp_name'];
move_uploaded_file($file_tmp_name, "./images/$nomPhoto");
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$postnom = $_POST['postnom'];
$naissance = $_POST['naissance'];
$sexe = $_POST['sexe'];
$pays = $_POST['pays'];
$nationalite = $_POST['nationalite'];
$adresse = $_POST['adresse'];
$surnom = $_POST['surnom'];
$religion = $_POST['religion'];
$pere = $_POST['pere'];
$telpere = $_POST['telpere'];
$adresse1 = $_POST['adresse1'];
$email = $_POST['email'];
$employeur = $_POST['employeur'];
$adresseemp = $_POST['adresseemp'];
$mere = $_POST['mere'];
$telmere = $_POST['telmere'];
$adresse2 = $_POST['adresse2'];
$email2 = $_POST['email2'];
$employeur1 = $_POST['employeur1'];
$adresseemp2 = $_POST['adresseemp2'];
$nom1 = $_POST['nom1'];
$adresse5 = $_POST['adresse5'];
$tel1 = $_POST['tel1'];
$nom2 = $_POST['nom2'];
$adresse6 = $_POST['adresse6'];
$tel2 = $_POST['tel2'];
$medenft = $_POST['medenft'];
$telmed = $_POST['telmed'];
$adressemed = $_POST['adressemed'];
$dentenft = $_POST['dentenft'];
$teldent = $_POST['teldent'];
$adressedent = $_POST['adressedent'];
$utile = $_POST['utile'];
$fam1 = $_POST['fam1'];
$age1 = $_POST['age1'];
$sex1 = $_POST['sex1'];
$fam2 = $_POST['fam2'];
$age2 = $_POST['age2'];
$sex2 = $_POST['sex2'];
$fam3 = $_POST['fam3'];
$age3 = $_POST['age3'];
$sex3 = $_POST['sex3'];
$fam4 = $_POST['fam4'];
$age4 = $_POST['age4'];
$sex4 = $_POST['sex4'];
$autresenft = $_POST['autresenft'];
$datedpt = $_POST['datedpt'];
$datepolio = $_POST['datepolio'];
$datecholera = $_POST['datecholera'];
$daterougeole = $_POST['daterougeole'];
$datejaune = $_POST['datejaune'];
$dateautres = $_POST['dateautres'];
$autremed = $_POST['autremed'];
$adresseautre = $_POST['adresseautre'];
$datefin = $_POST['datefin'];
$dateguide = $_POST['dateguide'];
$ecolefreq = $_POST['ecolefreq'];
$freq1 = $_POST['freq1'];
$freq2 = $_POST['freq2'];
$classefreq = $_POST['classefreq'];

$req = "insert into ELEVES(CLASSE,INSCRIPTION,PHOTO,NOM,PRENOM,POSTNOM,NAISSANCE,SEXE,PAYS,NATIONALITE,ADRESSE,SURNOM,RELIGION,PERE,TELPERE,ADRESSE1,EMAIL,EMPLOYEUR,ADRESSEEMP,MERE,TELMERE,ADRESSE2,EMAIL2,EMPLOYEUR1,ADRESSEEMP2,NOM1,ADRESSE5,TEL1,NOM2,ADRESSE6,TEL2,MEDENFT,TELMED,ADRESSEMED,DENTENFT,TELDENT,ADRESSEDENT,UTILE,FAM1,AGE1,SEX1,FAM2,AGE2,SEX2,FAM3,AGE3,SEX3,FAM4,AGE4,SEX4,AUTRESENFT,DATEDPT,DATEPOLIO,DATECHOLERA,DATEROUGEOLE,DATEJAUNE,DATEAUTRES,AUTREMED,ADRESSEAUTRE,DATEFIN,DATEGUIDE,ECOLEFREQ,FREQ1,FREQ2,CLASSEFREQ) values ('$classe','$inscription','$nomPhoto','$nom','$prenom','$postnom','$naissance','$sexe','$pays','$nationalite','$adresse','$surnom','$religion','$pere','$telpere','$adresse1','$email','$employeur','$adresseemp','$mere','$telmere','$adresse2','$email2','$employeur1','$adresseemp2','$nom1','$adresse5','$tel1','$nom2','$adresse6','$tel2','$medenft','$telmed','$adressemed','$dentenft','$teldent','$adressedent','$utile','$fam1','$age1','$sex1','$fam2','$age2','$sex2','$fam3','$age3','$sex3','$fam4','$age4','$sex4','$autresenft','$datedpt','$datepolio','$datecholera','$daterougeole','$datejaune','$dateautres','$autremed','$adresseautre','$datefin','$dateguide','$ecolefreq','$freq1','$freq2','$classefreq')";
mysql_query($req) or (die(mysql_error));
?>
<!DOCTYPE html>
<html>
<head lang="fr">
    <meta charset="utf-8">
    <title>Ajouter un Elève</title>
    <style type="text/css">
        body, td, th {
            font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
        }
    </style>
</head>
<body bgcolor="#3FACFC" leftmargin="50">
<h1 align="center">Jewels International School of Kinshasa <br>
    6705, Av. O.U.A., <br>
    Commune de Ngaliema Kinshasa, <br>
    Democratic Republic of Congo</h1>
<p align="center"><img src="logo/logo.png" width="140" height="134" alt=""/></p>

<form method="post" action="ajouterEleve.php" enctype="multipart/form-data">
  <p>
    <label>Grade/Classe:</label>
    <strong><?php echo($classe) ?></strong>
    <label><br>
      Date of inscription/Date d'Inscription:</label>
      <strong><?php echo($inscription) ?></strong>
    <label>
  </p>
  <p>    <img src="images/<?php echo($nomPhoto) ?>"width="90" height="113</label>
<h1 align="center">
    <p>
    <label><br>
    </label>
    <label>Name of Student/Nom de l'étudiant: Last/Nom:</label>
      <strong><?php echo($nom) ?></strong>
    <label> Name/Prenom:</label>
      <strong><?php echo($prenom) ?></strong>
    <label>Middle/Post-nom:</label>
      <strong><?php echo($postnom) ?><br></strong>
    <label><br>
      Date of Birth/Date de naissance:</label>
      <strong><?php echo($naissance) ?></strong>
    <br>
    <br>
    <label>Gender/Sexe:</label>
      <strong><?php echo($sexe) ?></strong>
    <label><br>
      COUNTRY OF BIRTH/PAYS DE NAISSANCE:</label>
      <strong><?php echo($pays) ?><br></strong>
    <label><br>
      NATIONALITY/NATIONALITE :</label>
      <strong><?php echo($nationalite) ?><br></strong>
    <label><br>
      ADDRESS/ADRESSE:</label>
      <strong><?php echo($adresse) ?><br></strong>
    <label><br>
      NAME BY WHICH THE CHILD IS MOST FREQUENTLY CALLED/NOM PAR LEQUEL L'ENFANT EST SOUVENT IDENTIFIE:</label>
    <?php echo($surnom) ?><br>
    <label><br>
      RELIGION :</label>
    <?php echo($religion) ?><br>
    <label><br>
      FATHER'S OR GUARDIAN'S NAME/NOM DU PERE ou TUTEUR:</label>
    <?php echo($pere) ?><br>
    <label><br>
      PHONE N°/NUMERO TEL.:</label>
    <?php echo($telpere) ?><br>
    <label><br>
      HOME ADDRESS/ADRESSE DU DOMICILE:</label>
    <?php echo($adresse1) ?><br>
    <label><br>
      E-MAIL ADDRESS/ADRESSE ELECTRONIQUE :</label>
    <?php echo($email) ?><br>
    <label><br>
      EMPLOYER/EMPLOYEUR - Company/Entreprise :</label>
    <label><?php echo($employeur) ?><br>
    <label><br>
      EMPLOYER'S ADDRESS/ADRESSE DE L'EMPLOYEUR:</label>
    <label><?php echo($adresseemp) ?><br>
    <label><br>
      MOTHER'S OR GUARDIAN'S NAME/NOM DE LA MERE ou TUTEUR :</label>
    <label><?php echo($mere) ?><br>
    <label><br>
      PHONE N°/NUMERO TEL.:</label>
    <label><?php echo($telmere) ?><br>
    <label><br>
      HOME ADDRESS/ADRESSE DU DOMICILE :</label>
    <label><?php echo($adresse2) ?><br>
    </p>
  </p>
  <p>(If different from above/Si différente de celle-ci-haut mentionnée)</p>
                        <label>
                            E-MAIL ADDRESS/ADRESSE ELECTRONIQUE :</label>
                        <label><?php echo($email2) ?><br>
                            <label><br>
                                EMPLOYER/EMPLOYEUR - Company/Entreprise:</label>
                            <label><?php echo($employeur1) ?><br>
                                <label><br>
                                    EMPLOYER'S ADDRESS/ADRESSE DE L'EMPLOYEUR :</label>
                                <label><?php echo($adresseemp2) ?>
                                    <label><br>
                                        <br>
  </label>
                                    <p>If neither parent nor guardian  can be reached in an emergency, contact:/En cas d’urgence, si le parent ou le  tuteur est injoignable, contacter:</p>
                                    <label>                                      NAME/NOM :</label>
                                    <?php echo($nom1) ?>
                                    <label> NAME/NOM :</label>
                                    <?php echo($nom2) ?>
                                    <label><br>
                                        <br>
                                        ADDRESS/ADRESSE:</label>
                                    <?php echo($adresse5) ?>
                                    <label> ADDRESS/ADRESSE:</label>
                                    <?php echo($adresse6) ?>
                                    <label><br>
                                        <br>
                                        PHONE N°/NUM. TEL.:</label>
                                    <?php echo($tel1) ?>
                                    <label> PHONE N°/NUM. TEL.:</label>
                                    <?php echo($tel2) ?>
                                    <label><br>
                                        <br>
                                        CHILD'S DOCTOR/MEDECIN DE L'ENFANT :</label>
                                    <?php echo($medenft) ?>
                                    <label> PHONE N°/NUM. TEL.:</label>
                                    <?php echo($telmed) ?><br>
                                    <label><br>
                                        DOCTOR'S ADDRESS/ADRESSE DU MEDECIN :</label>
                                    <?php echo($adressemed) ?><br>
                                    <label><br>
                                        CHILD'S DENTIST/DENTISTE DE L'ENFANT :</label>
                                    <?php echo($dentenft) ?>
                                    <label> PHONE N°/NUM. TEL.:</label>
                                    <?php echo($teldent) ?><br>
                                    <label><br>
                                        DENTIST'S ADDRESS/ADRESSE DU DENTISTE:</label>
                                    <?php echo($adressedent) ?><br>
                                    <label><br>
                                        Please give any information concerning your child which you think may be helpful
                                        to us.
                                        (PLAY AND EATING HABITS, FEARS, LIKES AND DISLIKES, CHRONIC HEALTH CONDITIONS &
                                        MEDICATIONS - ASTHMA, ALLERGIES, ETC.)/
                                        Veuillez fournir toute information utile concernant l'enfant.
                                        (DIVERTISSEMENT & REGIME ALIMENTAIRE, PEURS, PREFERENCES & AVERSIONS, MALADIES
                                        CHRONIQUES & MEDICAMENTS - ASTHME, ALLERGIES, ETC.)
                                        :</label>
                                    <?php echo($utile) ?><br>
                                    <label><br>
                                        Other children in family/Autres enfants dans la famille :</label>
                                    <?php echo($fam1) ?>
                                    <label> Age:</label>
                                    <?php echo($age1) ?>
                                    <label>Gender/Sexe:</label>
                                    <?php echo($sex1) ?><br>
                                    <label><br>
                                        Other children in family/Autres enfants dans la famille :</label>
                                    <?php echo($fam2) ?>
                                    <label> Age:</label>
                                    <?php echo($age2) ?>
                                    <label>Gender/Sexe:</label>
                                    <?php echo($sex2) ?><br>
                                    <label><br>
                                        Other children in family/Autres enfants dans la famille :</label>
                                    <?php echo($fam3) ?>
                                    <label> Age:</label>
                                    <?php echo($age3) ?>
                                    <label>Gender/Sexe:</label>
                                    <?php echo($sex3) ?><br>
                                    <label><br>
                                        Other children in family/Autres enfants dans la famille :</label>
                                    <?php echo($fam4) ?>
                                    <label> Age:</label>
                                    <?php echo($age4) ?>
                                    <label>Gender/Sexe:</label>
                                    <?php echo($sex4) ?><br>
                                    <label><br>
                                        List other adults in the family (relation to child)/Autres enfants dans la
                                        famille (relations avec l'enfant):</label>
                                    <?php echo($autresenft) ?><br>

                                    <P>IMMUNIZATION RECORD/CARNET DE VACCINATION: (Please enter the date of the last
                                        immunization/Veuillez indiquer la date du dernier vaccine.)</P>
  <table width="80" border="1">
                                        <tr>
                                            <td><strong>Immunization/Vaccin </strong></td>
                                            <td><strong>Date</strong></td>
                                            <td><strong>Immunization/Vaccin</strong></td>
                                            <td><strong>Date</strong></td>
                                        </tr>
                                        <tr>
                                            <td>DPT/Diphtérie:</td>
                                            <td><?php echo($datedpt) ?></td>
                                            <td>MMR/Rougeole:</td>
                                            <td><?php echo($daterougeole) ?></td>
                                        </tr>
                                        <tr>
                                            <td>Oral Polio/Polio Oral:</td>
                                            <td><?php echo($datepolio) ?></td>
                                            <td>Yellow fever/FièvreJaune:</td>
                                            <td><?php echo($datejaune) ?></td>
                                        </tr>
                                        <tr>
                                            <td>Cholera:</td>
                                            <td><?php echo($datecholera) ?></td>
                                            <td>Other/Autre:</td>
                                            <td><?php echo($dateautres) ?></td>
                                        </tr>
  </table>
                                    <label><br>
                                        Should an emergency arise, I hereby give my permission to the school to call a
                                        doctor for medical or surgical care for my child. /
                                        En cas d'urgence, j'autorise l'école à faire appel à un médecin pour une
                                        éventuelle intervention médicale ou chirurgicale en faveur de mon enfant:
                                    </label>
                                    <?php echo($autremed) ?>
                                    It is understood that a conscientious effort will be made to locate me or/Il est
                                    entendu qu'un effort devra être fourni au préalable pour me localiser ou </label>
                                <?php echo($adresseautre) ?>before any action is taken, but if it
                                is not possible to contact me, I will accept this action. I accept all the emergency
                                treatment charges/avant d'entreprendre quelque action que ce soit; mais s'il n'est pas
                                possible de me contacter, j'accepterai toute action entreprise par l'école. Je m'engage
                                donc à m'acquitter des frais d'urgence.
                                <label><br>
                                    <br>
                                    Date: </label>
                                <?php echo($datefin) ?>
                                <br>
                                <br>FIELD TRIPS/VISITES GUIDEES

                                I give permission for child to go on trips away from the premises of the school, whether
                                on foot or by vehicle.

                                Pour les activités parascolaires, j'autorise aussi mon enfant d'aller en visite guidée
                                en dehors de l'école, à pied ou en véhicule, sous l'encadrement de l'enseignant.
                                <label><br>
                                    <br>
                                    Date: </label>
                                <?php echo($dateguide) ?>
                                <br>
                                <label><br>
                                    <strong>PREVIOUS SCHOOL/ECOLE ANTERIEURE </strong><br>
                                    <br>NAME OF PREVIOUS SCHOOL ATTENDED (IF NOT JEWELS)/NOM DE L'ECOLE PRECEDENTE (SI
                                    PAS JEWELS)
                                    :</label>
                                <?php echo($ecolefreq) ?><br>
                                <label><br>
                                    DATE STUDENT ATTENDED/PERIODE DE FREQUENTATION: From/De: </label>
                                <?php echo($freq1) ?> To/A : </label> <?php echo($freq2) ?>
                            <label><br>
                                <br>
  GRADE COMPLETED/CLASSE FREQUENTEE :</label>
                            <?php echo($classefreq) ?><br>
                            <br>
                            <br>
                            <br>

                            <label></label><input type="submit" value="Enregistrer"><br>
</form>
</body>
</html>


Question : est-il possible d'ajouter un bouton pour enregistrer en pdf et le bouton impression?
Question : est ce possible au moment de submit que l'enregistrement s'exporte automatiquement en pdf dans un dossier défini?
0
jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 4 649
26 nov. 2014 à 10:02
Bonjour,
Qui dit : Autre souci .. dit NOUVELLE QUESTION.

Je t'invite donc à clore ce sujet ( en cliquant sur le lien marquer comme résolu) puis à ouvrir une nouvelle discussion pour exposer ce "nouveau" souci.
0
tridam23 Messages postés 99 Date d'inscription mercredi 5 novembre 2014 Statut Membre Dernière intervention 11 juin 2021 > jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024
26 nov. 2014 à 10:08
ok
0