Bonjour,
j'ai un fichier "Message.txt" avec:
je voudrais réussir a ceci et ajouter une balise en plus:
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part <item><url>test1</url></item>
je voudrais ajouter au fur et mesure plusieurs lignes similaire via le fichier add.php
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <playlist> <item><url>test1</url></item> <item><url>test2</url></item> <item><url>test3</url></item>...etc </playlist>
Le tout via une page html.
fichier add.php:
Code html : 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 <?php if(isset($_POST['submitSave'])){ require 'simplexml.class.php'; $value = simplexml_load_file('Message.txt'); $value->addChild('name', $_POST["value"]); file_put_contents('Message.txt', $value->asXML()); header('location: message.php'); } ?> <form method="post"> <center><br><br><table cellpadding="2" cellspacing="2"> <tr> <td>Adresse</td> <td><input type="text" name="value"></td> </tr> <tr> <td> </td> <td><input type="submit" name="submitSave" value="Save"></td> </tr> </table> </form> <head> <style> body { background-color: #A4A4A4; } </style> </head> <body> </body>
le fichier message.php qui affiche en forme de tableau la liste ajouter par le fichier add.php:
Le fichier "Message.txt" sera utiliser par un autre programme en tant que playlist , mais il me faut ajouter la balise <playlist></playlist> au debut et à la fin , ça fait quelques jours que je cherche la solution mais mes connaissances en php sont encore trop basique.
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 <?php if(isset($_GET['action'])){ $item = simplexml_load_file('Message.txt'); $value = $_GET['value']; $index = 0; $i = 0; foreach ($item->name as $name){ if($name['value']==$value){ $index = $i; break; } $i++; } unset($item->name[$index]); file_put_contents('Message.txt', $item->asXML()); } $item = simplexml_load_file('Message.txt'); echo 'Liste nombre: '.count($item); echo '<br>Listing Information'; ?> <br> <center><a href="add.php">Add new adresse</a> <br> <br> <center><table cellpadding="3" cellspacing="3" border="2"> <tr> <th>Adresse</th> <th>Option</th> </tr> <?php foreach ($item->name as $name){ ?> <tr> <td><?php echo $name; ?></td> <td align="center"> <a href="edit.php?value=<?php echo $name; ?>">Edit</a> <a href="message.php?action=delete&value=<?php echo $name; ?>" onclick="return confirm('vous etes sur?')">Delete</td> </tr> <?php } ?> </table> <head> <style> body { background-color: #A4A4A4; } </style> </head> <body> </body>
help![]()
Partager