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

PHP & Base de données Discussion :

Transfère d'une table a l'autre


Sujet :

PHP & Base de données

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Technicien réseau
    Inscrit en
    Mars 2019
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Technicien réseau
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Mars 2019
    Messages : 6
    Points : 1
    Points
    1
    Par défaut Transfère d'une table a l'autre
    Bonjour à tous, Je m'adresse à vous aujourd'hui car j'ai un problème, plutôt un manque de connaissance.

    je compte créé un site qui me permet de gérer mes affaire donc j'ai une page "créé une affaire","affaire en cours" et "affaire archiver";
    J'ai aussi une BDD avec deux table, une "en_cours" et l'autre "archive".

    je précise que ma page "créé une affaire" est un formulaire html qui rentre toutes les données dans ma BDD et rentre tous dans la table "en_cours";
    la page "affaire en cours" ne fait qu'afficher la table "en_cours" sous formes de tableaux.

    Sur ma page "affaire en cours" j'ai un tableaux avec mes variables et je voudrais créé un bouton qui sélectionne la ligne du tableaux et
    la transfère de la table "en_cours" à "archive".

    voici mes differents codes;
    Ma page archive :

    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
    <!DOCTYPE html>
    <html>
    <head>
    	<meta charset="utf-8">
    	<link rel="stylesheet" type="text/css" href="style_en_cours.css">
    	<title>Logiciels | Fico</title>
    </head>
    <body>
    	<h1>Fico'Graphie</h1>
    <?php include 'menu.php'; ?>
     
    <?php
    	include 'database.php';
    	global $db;
    	?>
    <br>
    <input type="button" id="supprimer" name="supprimer" value="Supprimer" onclick="">
     
    <br><br>
    	<?php 	
    	$q = $db->query("SELECT * FROM archive");	
    	while ($en_cours = $q->fetch()) { ?>
     
    		<table>
    			<tr>
    			<th>Id</th> <th>Date d'ouverture</th> <th>Rendu</th> <th>Statut</th> <th>Client</th> 
    			<th>Affaire</th> <th>Type</th> <th>Prestations</th><th>Etat</th> <th>Commentaires</th> 
    			<th>Quantité</th> <th>Livraison</th> <th>N° BL</th> <th>Date fac. </th> <th>C.A.</th> 
    			<th>Achats</th> <th>MB</th> <th>CC</th> <th>CA</th><th>Action</th>
    		</tr>
    		<tr>
    			<td style="font-size: 100%"><?= $en_cours['id']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['date_ouv']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['date_ren']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['statut']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['client']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['affaire']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['type']; ?></td>
    			<td style="font-size: 100%">
    				<?= $en_cours['pres']; ?>,
    				<?= $en_cours['list2']; ?>,
    				<?= $en_cours['list3']; ?>,
    				<?= $en_cours['list4']; ?>,
    				<?= $en_cours['list5']; ?>,
    				<?= $en_cours['list6']; ?>,
    				<?= $en_cours['list7']; ?>,
    				<?= $en_cours['list8']; ?>	
    			</td>
    			<td style="font-size: 100%"><?= $en_cours['etat']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['commentaires']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['quantite']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['date_liv']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['nbl']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['date_fac']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['ca']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['achats']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['mb']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['cc']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['c_a']; ?></td>
    		</tr>
    		</table>
    <?php	}
     
    ?>
    </body>
    </html>
     
    Voici ma page "affaire en cours" :
     
    <!DOCTYPE html>
    <html>
    <head>
    	<meta charset="utf-8">
    	<link rel="stylesheet" type="text/css" href="style_en_cours.css">
    	<title>Logiciels | Fico</title>
    </head>
    <body>
    	<h1>Fico'Graphie</h1>
     
    <?php include 'menu.php'; ?>
     
    <?php
    	include 'database.php';
    	global $db;
    	?>
    <br>
     
    <input type="button" id="archiver" name="archiver" value="Archiver" onclick="????">
    <input type="button" id="dupliquer" name="dupliquer" value="Dupliquer" onclick="??????" >
    <input type="button" id="supprimer" name="supprimer" value="Supprimer" onclick="?????">
    <br><br>
     
    	<?php 	
    	$q = $db->query("SELECT * FROM en_cours");	
    	while ($en_cours = $q->fetch()) { ?>
    		<table>
     
    			<tr>
    			<th>Id</th> <th>Date d'ouverture</th> <th>Rendu</th> <th>Statut</th> <th>Client</th> 
    			<th>Affaire</th> <th>Type</th> <th>Prestations</th><th>Etat</th> <th>Commentaires</th> 
    			<th>Quantité</th> <th>Livraison</th> <th>N° BL</th> <th>Date fac. </th> <th>C.A.</th> 
    			<th>Achats</th> <th>MB</th> <th>CC</th> <th>CA</th><th>Action</th>
    		</tr>
    		<tr>
    			<td style="font-size: 100%"><?= $en_cours['id']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['date_ouv']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['date_ren']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['statut']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['client']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['affaire']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['type']; ?></td>
    			<td style="font-size: 100%">
    				<?= $en_cours['pres']; ?>,
    				<?= $en_cours['list2']; ?>,
    				<?= $en_cours['list3']; ?>,
    				<?= $en_cours['list4']; ?>,
    				<?= $en_cours['list5']; ?>,
    				<?= $en_cours['list6']; ?>,
    				<?= $en_cours['list7']; ?>,
    				<?= $en_cours['list8']; ?>	
    			</td>
    			<td style="font-size: 100%"><?= $en_cours['etat']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['commentaires']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['quantite']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['date_liv']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['nbl']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['date_fac']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['ca']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['achats']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['mb']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['cc']; ?></td>
    			<td style="font-size: 100%"><?= $en_cours['c_a']; ?></td>
    		</tr>
    		</table>
    <?php	}
     
    ?>
    </body>
    </html>

    Voici ma BDD sous forme de code sql :



    Code sql : 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
    -- phpMyAdmin SQL Dump
    -- version 4.8.3
    -- <a href="https://www.phpmyadmin.net/" target="_blank">https://www.phpmyadmin.net/</a>
    --
    -- Hôte : 127.0.0.1:3306
    -- Généré le :  mer. 20 mars 2019 à 13:30
    -- Version du serveur :  5.7.23
    -- Version de PHP :  7.2.10
     
    SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
    SET AUTOCOMMIT = 0;
    START TRANSACTION;
    SET time_zone = "+00:00";
     
     
    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8mb4 */;
     
    --
    -- Base de données :  `ficog`
    --
     
    -- --------------------------------------------------------
     
    --
    -- Structure de la table `archive`
    --
     
    DROP TABLE IF EXISTS `archive`;
    CREATE TABLE IF NOT EXISTS `archive` (
      `id` bigint(20) NOT NULL AUTO_INCREMENT,
      `date_ouv` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `date_ren` text NOT NULL,
      `statut` varchar(30) NOT NULL,
      `client` varchar(255) NOT NULL,
      `affaire` varchar(255) NOT NULL,
      `type` varchar(200) NOT NULL,
      `pres` varchar(200) DEFAULT NULL,
      `list2` varchar(15) DEFAULT NULL,
      `list3` varchar(15) DEFAULT NULL,
      `list4` varchar(15) DEFAULT NULL,
      `list5` varchar(15) DEFAULT NULL,
      `list6` varchar(15) DEFAULT NULL,
      `list7` varchar(15) DEFAULT NULL,
      `list8` varchar(15) DEFAULT NULL,
      `etat` varchar(200) NOT NULL,
      `commentaires` mediumtext,
      `quantite` mediumtext NOT NULL,
      `date_liv` text,
      `nbl` longtext NOT NULL,
      `date_fac` text,
      `ca` longtext NOT NULL,
      `achats` longtext NOT NULL,
      `mb` longtext NOT NULL,
      `cc` varchar(10) NOT NULL,
      `c_a` varchar(10) NOT NULL,
      PRIMARY KEY (`id`) USING BTREE
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
     
    -- --------------------------------------------------------
     
    --
    -- Structure de la table `en_cours`
    --
     
    DROP TABLE IF EXISTS `en_cours`;
    CREATE TABLE IF NOT EXISTS `en_cours` (
      `id` bigint(20) NOT NULL AUTO_INCREMENT,
      `date_ouv` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `date_ren` text NOT NULL,
      `statut` varchar(30) NOT NULL,
      `client` varchar(255) NOT NULL,
      `affaire` varchar(255) NOT NULL,
      `type` varchar(200) NOT NULL,
      `pres` varchar(200) DEFAULT NULL,
      `list2` varchar(15) DEFAULT NULL,
      `list3` varchar(15) DEFAULT NULL,
      `list4` varchar(15) DEFAULT NULL,
      `list5` varchar(15) DEFAULT NULL,
      `list6` varchar(15) DEFAULT NULL,
      `list7` varchar(15) DEFAULT NULL,
      `list8` varchar(15) DEFAULT NULL,
      `etat` varchar(200) NOT NULL,
      `commentaires` mediumtext,
      `quantite` mediumtext NOT NULL,
      `date_liv` text,
      `nbl` longtext NOT NULL,
      `date_fac` text,
      `ca` longtext NOT NULL,
      `achats` longtext NOT NULL,
      `mb` longtext NOT NULL,
      `cc` varchar(10) NOT NULL,
      `c_a` varchar(10) NOT NULL,
      PRIMARY KEY (`id`) USING BTREE
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    COMMIT;
     
    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

    Je précise que je débute le php et mysql donc si mes codes sont pas optimises ou avec de mauvaise pratique j'en suis désoler et j'accepte toute critiques.
    Merci

  2. #2
    Expert éminent sénior
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Points : 16 545
    Points
    16 545
    Billets dans le blog
    12
    Par défaut
    Salut,

    Citation Envoyé par Akuseru__ Voir le message
    J'ai aussi une BDD avec deux table, une "en_cours" et l'autre "archive".
    Euh, pourquoi dupliquer et surtout se compliquer la vie ? Tu rajoute un champ est_archive à ta table et le tour est joué.

    Ensuite, sur MySQL il vaut mieux privilégier le moteur InnoDB à MyISAM et ce dans presque 99% des cas (et dans ton cas aussi)

Discussions similaires

  1. Réponses: 2
    Dernier message: 26/04/2007, 16h32
  2. Réponses: 7
    Dernier message: 23/11/2006, 10h45
  3. Copie de données d'une table à l'autre
    Par ganga dans le forum Langage SQL
    Réponses: 1
    Dernier message: 23/11/2006, 08h34
  4. Réponses: 4
    Dernier message: 25/08/2006, 00h25
  5. Ajout & modif d'une table vers l'autre
    Par BOTIGUA dans le forum Access
    Réponses: 1
    Dernier message: 17/02/2006, 18h00

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