Bonjour,

A la place d'utuliser une db sql je voudrais utiliser un fichier .xml que dois je changer à mon programme ?

db sql :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
CREATE TABLE `inlinemod` (
  `id` 			int(11) NOT NULL auto_increment,
  `nom` 		varchar(255) NOT NULL default '',
  `prenom` 		varchar(255) NOT NULL default '',
  `adresse`		tinytext NOT NULL,
  `code_postal`		varchar(5) NOT NULL default '',
  `ville` 		varchar(255) NOT NULL default '',
  `enfants`		int(11) NOT NULL default '0',
  `email` 		varchar(255) NOT NULL default '',
  PRIMARY KEY  (`id`)
)
index.php

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
 
<?php
	//Connexion à la base de données
  $DB_HOST = "127.0.0.1";
  $DB_USER = "root";
  $DB_PASSWORD = "";
  $DB_NAME = "dbtest";
  $DB_TABLE_NAME = "inlinemod";
 
 
  $connexion = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD) or die(mysql_error());
  mysql_select_db($DB_NAME, $connexion) or die(mysql_error());
 
	$sql = "SELECT * FROM `" . $DB_TABLE_NAME . "`";
	$req = mysql_query($sql) or die(mysql_error());
 
	mysql_close($connexion);
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
 
		<title>Modification "Inline" d'éléments dans une page web</title>
 
		<link rel="StyleSheet" type="text/css" href="index.css"/>
		<script type="text/javascript" src="inlinemod.js"></script>
  </head>
 
  <body>
	<h1>Liste d'utilisateurs</h1>
 
 
	<table id="table-utilisateurs">
		<tr>
			<th>Nom</th>
			<th>Prénom</th>
			<th>Adresse</th>
			<th>Code Postal</th>
			<th>Ville</th>
			<th>Enfants</th>
			<th>Email</th>
		</tr>
 
	<?php
	while ($user = mysql_fetch_assoc($req))
	{
	?>
		<tr>
			<td id="nom-<?php echo $user['id']; ?>"  class="cellule" ondblclick="inlineMod(<?php echo $user['id']; ?>, this, 'nom', 'texte')"><?php echo $user['nom']; ?></td>
 
			<td id="prenom-<?php echo $user['id']; ?>"  class="cellule" ondblclick="inlineMod(<?php echo $user['id']; ?>, this, 'prenom', 'texte')"><?php echo $user['prenom']; ?></td>
 
			<td id="adresse-<?php echo $user['id']; ?>"  class="cellule" ondblclick="inlineMod(<?php echo $user['id']; ?>, this, 'adresse', 'texte-multi')"><?php echo $user['adresse']; ?></td>
 
			<td id="cp-<?php echo $user['id']; ?>"  class="cellule" ondblclick="inlineMod(<?php echo $user['id']; ?>, this, 'code_postal', 'texte')"><?php echo $user['code_postal']; ?></td>
 
			<td id="ville-<?php echo $user['id']; ?>"  class="cellule" ondblclick="inlineMod(<?php echo $user['id']; ?>, this, 'ville', 'texte')"><?php echo $user['ville']; ?></td>
 
			<td id="enfants-<?php echo $user['id']; ?>"  class="cellule" ondblclick="inlineMod(<?php echo $user['id']; ?>, this, 'enfants', 'nombre')"><?php echo $user['enfants']; ?></td>
 
			<td id="email-<?php echo $user['id']; ?>"  class="cellule" ondblclick="inlineMod(<?php echo $user['id']; ?>, this, 'email', 'texte')"><?php echo $user['email']; ?></td>
		</tr>
	<?php
	}
	?>
	</table>
 
	<div id="info">(les données de ce tableau sont fictives)</div>
 
  </body>
  </html>
 sauverMod.php
sauverMod.php

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
  $DB_HOST = '127.0.0.1';
  $DB_USER = 'root';
  $DB_PASSWORD = '';
  $DB_NAME = 'dbtest';
  $DB_TABLE_NAME = 'inlinemod';
//On sort en cas de paramètre manquant ou invalide
if(empty($_GET['id']) or empty($_GET['type']) or empty($_GET['champ']) or empty($_GET['valeur'])
   or !is_numeric($_GET['id'])
   or !in_array(
   		$_GET['champ'],
        array('nom', 'prenom', 'adresse', 'code_postal', 'ville', 'enfants', 'email')
        ))
{
    exit;
}
 
    //Connexion à la base de données
    $connexion = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD) or die(mysql_error());
    mysql_select_db($DB_NAME, $connexion) or die(mysql_error());
 
    //Construction de la requête en fonction du type de valeur
switch($_GET['type'])
{
    case 'texte':
    case 'texte-multi':
        $sql  = 'UPDATE `'.$DB_TABLE_NAME;
        $sql .= '` SET ' . mysql_real_escape_string($_GET['champ']) . '="';
        $sql .= mysql_real_escape_string($_GET['valeur']) . '" WHERE id=' . intval($_GET['id']);
        break;
 
    case 'nombre':
        $sql  = 'UPDATE `'.DB_TABLE_NAME;
        $sql .= '` SET ' . mysql_real_escape_string($_GET['champ']) . '=' . intval($_GET['valeur']);
        $sql .= ' WHERE id=' . intval($_GET['id']);
        break;
 
    default:
        exit;
}
    //Exécution de la requête
    mysql_query($sql) or die(mysql_error());
 
    mysql_close($connexion);
?>

Merci à vous