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 |
Partager