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

Bibliothèques et frameworks PHP Discussion :

[SimpleXML] Modifier attribut via formulaire


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Février 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2012
    Messages : 2
    Points : 1
    Points
    1
    Par défaut [SimpleXML] Modifier attribut via formulaire
    Bonjour à tous,

    j'ai fait un petit bout de code me permettant d'afficher les donné d'un fichier xml que je retranscrit sous forme de tableau, jusque l'a pas de problème ! maintenant j'aimerais faire une page de "gestion" de ce tableau pour pouvoir modifier l'attribut de la valeur "prix" j'ai commencer a essayer de faire le formulaire mais je ne vois pas trop ou le mettre et surtout comment faire pour modifier les attribut. Je vous joint le code

    Code proute.xml : 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
    <?xml version="1.0" encoding="UTF-8" ?>
    <document>
     
    	<categorie>
     
    		<date>
    			<semaine>2/06 au 9/06</semaine>
    			<semaine>9/06 au 16/06</semaine>
    			<semaine>16/6 au 23/06</semaine>
    			<semaine>23/06 au 30/06</semaine>
    			<semaine>30/06 au 07/07</semaine>
    			<semaine>07/07 au 14/07</semaine>
    			<semaine>14/07 au 21/07</semaine>
    			<semaine>21/07 au 28/07</semaine>
    			<semaine>28/07 au 04/08</semaine>
    			<semaine>04/08 au 11/08</semaine>
    			<semaine>11/08 au 18/08</semaine>
    			<semaine>18/08 au 25/08</semaine>
    			<semaine>25/08 au 01/09</semaine>
    			<semaine>01/09 au 08/09</semaine>
    			<semaine>08/09 au 15/09</semaine>
    			<semaine>15/09 au 22/09</semaine>
    			<semaine>22/09 au 29/09</semaine>
    		</date>
     
    		<appart>
    			<numero>101</numero>
    				<personne>4 (6)*</personne>
    					<prix choix="reserve">650 €</prix>
    					<prix choix="libre">650 €</prix> 	
    					<prix choix="reserve">650 €</prix>	
    					<prix choix="option">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="option">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">850 €</prix>
    					<prix choix="libre">720 €</prix>
    					<prix choix="reserve">720 €</prix>
    		</appart>
     
     
    	</categorie>
     
    </document>

    Code proute.php : 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
    <html>
    <head>
    	<meta charset="utf-8" />
    	<!-- CSS -->
    	<link rel="stylesheet" href="./utils/style.css" />
    	<style type="text/css">
    		body { font-family: comic sans ms, helvetica, arial; font-size: 12px;}
    		table { border-collapse: collapse; font-size: 12px;}
    		caption { font-size: 18px; font-weight: bold; margin: 0 0 10px 0;}
    		th { font-size: 13px; padding: 5px 5px 10px 5px; text-align: center;}
    		tr { text-align: center;}
    		tr#semaine {font-weight: bold; font-style: oblique;}
    		tr#semaine td {width: 45px;}
    		tr.gris {background: #CCD396;}
    		td { padding: 5px 5px 5px 5px; text-align: center;}
    		td a {color: #242834; display: block; width: 100%; height: 100%; text-decoration: none;}
    		td a:hover { background: #C6CE88;}
    		tr.gris td a {color: #242834; display: block; width: 100%; height: 100%; text-decoration: none;}
    		tr.gris td a:hover { background: #C4C0C0;}
    		td.appart { font-weight: bold;}
    		td.red { background: red; color: #ffffff; border: 1px solid black;}
    		td.orange { background: #FFAE00;} 
    	</style>
    	<title>Gestion disponibilite</title>
    </head>
     
    <body>
     
    <?php
     
    $document = simplexml_load_file('proute.xml');
     
     
     
    	foreach ($document->categorie as $categorie) {
     
     
    		echo '<table border="1px">';
     
    		echo '<caption>Calendrier des réservations</caption>';
     
    		echo '<tr><th>Numéro d\'appartement</th><th>Nombre de personne</th><th colspan="17">Semaine</th></tr>';
     
    		foreach ($categorie->date as $date) {
     
    			echo '<tr>';
    			echo '<td></td>';
    			echo '<td></td>';
     
    			foreach ($date->semaine as $semaine) {
     
    				echo '<td>' . $semaine . '</td>';
    			}
     
    			echo '</tr>';
     
    		}
     
     
    		foreach($categorie->appart as $appart) {
     
     
    			echo '<tr>';
     
    			foreach ($appart->numero as $numero) {
     
    				echo '<td>' . $numero . '</td>';
    			}
     
    			foreach ($appart->personne as $personne) {
     
    				echo '<td>' . $personne . '</td>';
    			}
     
    			foreach ($appart->prix as $prix) {
     
    				echo '<td><select name="choix"><option value="'.$prix[choix].'">libre</option><option value="reserve">reserve</option><option value="option">option</option></select>'. $prix . '</td>';				
    			}
     
    			echo '</tr>';	
     
    		}
     
     
     
    		echo '</table>';
     
     
    	}
     
     
     
     
     
    ?>
     
     
    </body>
    </html>


    merci de votre aide

  2. #2
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Février 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2012
    Messages : 2
    Points : 1
    Points
    1
    Par défaut
    Pour ce qui est de la mise en place du formulaire je pense avoir réussi a faire ce petit truc ! Maintenant le problème est de recup les données multiple et de les traiter si quelqu'un avais un indice

    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
     
    <html>
    <head>
    	<meta charset="utf-8" />
    	<!-- CSS -->
    	<link rel="stylesheet" href="./utils/style.css" />
    	<style type="text/css">
    		body { font-family: comic sans ms, helvetica, arial; font-size: 12px;}
    		table { border-collapse: collapse; font-size: 12px;}
    		caption { font-size: 18px; font-weight: bold; margin: 0 0 10px 0;}
    		th { font-size: 13px; padding: 5px 5px 10px 5px; text-align: center;}
    		tr { text-align: center;}
    		tr#semaine {font-weight: bold; font-style: oblique;}
    		tr#semaine td {width: 45px;}
    		tr.gris {background: #CCD396;}
    		td { padding: 5px 5px 5px 5px; text-align: center;}
    		td a {color: #242834; display: block; width: 100%; height: 100%; text-decoration: none;}
    		td a:hover { background: #C6CE88;}
    		tr.gris td a {color: #242834; display: block; width: 100%; height: 100%; text-decoration: none;}
    		tr.gris td a:hover { background: #C4C0C0;}
    		td.appart { font-weight: bold;}
    		td.red { background: red; color: #ffffff; border: 1px solid black;}
    		td.orange { background: #FFAE00;} 
    	</style>
    	<title>Gestion disponibilite</title>
    </head>
     
    <body>
     
    <?php
     
    $document = simplexml_load_file('proute.xml');
     
     
     
    	foreach ($document->categorie as $categorie) {
     
    		echo '<form action="proute.php" method="post">';
     
    		echo '<table border="1px">';
     
    		echo '<caption>Calendrier des réservations</caption>';
     
    		echo '<tr><th>Numéro d\'appartement</th><th>Nombre de personne</th><th colspan="17">Semaine</th></tr>';
     
    		foreach ($categorie->date as $date) {
     
    			echo '<tr>';
    			echo '<td></td>';
    			echo '<td></td>';
     
    			foreach ($date->semaine as $semaine) {
     
    				echo '<td>' . $semaine . '</td>';
    			}
     
    			echo '</tr>';
     
    		}
     
     
    		foreach($categorie->appart as $appart) {
     
     
    			echo '<tr>';
     
     
    			foreach ($appart->numero as $numero) {
     
    				echo '<td>' . $numero . '</td>';
    			}
     
    			foreach ($appart->personne as $personne) {
     
    				echo '<td>' . $personne . '</td>';
    			}
     
     
    			foreach ($appart->prix as $prix) {
     
    				echo '<td><select name="choix"><option value="'.$prix[choix].'">libre</option><option value="reserve">reserve</option><option value="option">option</option></select>'. $prix . '</td>';	
     
    			}
     
     
    			echo '</tr>';	
     
     
    		}
     
     
    		echo '</table>';
     
    		echo '<input type="submit" value="Enregistrer" />';
     
    		echo '</form>';
     
     
    	}
     
     
     
    ?>
     
     
    </body>
    </html>

Discussions similaires

  1. Modifier .docx via formulaire
    Par Magicarpe dans le forum Langage
    Réponses: 13
    Dernier message: 17/11/2015, 12h10
  2. Modifier produit via formulaire + bdd
    Par fredaster31 dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 12/12/2012, 16h45
  3. [AC-2007] Modifier valeur de table via formulaire
    Par amartik dans le forum IHM
    Réponses: 2
    Dernier message: 12/01/2010, 11h44
  4. modifier champs requetes via formulaire
    Par QUALIF dans le forum IHM
    Réponses: 1
    Dernier message: 12/02/2008, 21h07
  5. [SQL] Modifier donnés base via formulaire
    Par rane dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 26/07/2007, 14h44

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