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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="design.css" />
<title>Modifier un champs CSV dans la base de données...</title>
<script type="text/javascript">
<!--
function ajouterChampsCsv() {
var xhr;
if(window.XMLHttpRequest || window.ActiveXObject) {
if(window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
}
else {
alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
return;
}
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
document.getElementById("real").innerHTML = "Modification réalisé avec succés !!!";
}
else if(xhr.readyState == 2 || xhr.readyState == 3 || xhr.readyState == 1) {
document.getElementById("real").innerHTML = "<p>Chargement en cours</p>";
}
}
var bdd = encodeURIComponent(document.getElementById("<?php echo $nomColonneBd; ?>").value);
var csv = encodeURIComponent(document.getElementById("<?php echo $nomColonneCsv; ?>").value);
xhr.open("GET", "modifierChamps.php?bd="+bdd+"&CSV="+csv+"", true);
xhr.send(null);
}
//-->
</script>
</head>
<body>
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('test');
?>
<table>
<tr>
<th>Champs base de données</th>
<th>Champs de la colonne CSV</th>
<th>Modifier</th>
</tr>
<?php
$reqChamps = mysql_query("SELECT nomColonneBd, nomColonneCsv FROM champs");
while($resChamps = mysql_fetch_array($reqChamps)) {
$nomColonneBd = $resChamps['nomColonneBd'];
$nomColonneCsv = $resChamps['nomColonneCsv'];
echo '
<tr>
<td>'.$resChamps['nomColonneBd'].'</td>
<td>'.$resChamps['nomColonneCsv'].'</td>
<td><input type="text" id="'.$nomColonneBd.'" /></td>
<input type="hidden" id="'.$nomColonneCsv.'" />
<div id="real"></div>
</tr>
';
}
if($_GET['bd'] && $_GET['CSV']) {
$CSV = $_GET['CSV'];
$bd = $_GET['bd'];
//mysql_query("UPDATE champs SET nomColonneCsv='".$CSV."' WHERE nomColonneBd='".$bd."'");
}
?>
</table>
<br>
<center><input type="button" value="Envoyer" onclick="ajouterChampsCsv();" /></center>
</body>
</html> |
Partager