<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<title>Efface SQL</title>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<body>
<?php
// bts2m.free.fr/Wifi/VI_efface.php?table=1&Idmax=10&Idmin=1
// roupet.free.fr/informatique/mysql.php
//--Connexion au serveur
define("NOM","tpil.projet"); //nom = login chez free
define("PASSE","MotDePasse"); // passe=votre mot de passe free
define("SERVEUR","sql.free.fr"); // adresse du serveur free
$link = mysql_connect(SERVEUR,NOM,PASSE);
$table='mesures';
$titre='mesuresTitre';
if(!$link) {echo"Impossible de se connecter au serveur".mysql_error();exit;}
else {echo "<h2>Connexion au serveur réussie !</h2>\n";}
if (isset($_GET['table'])) {
$table='mesures'.$_GET['table'];
$titre='mesuresTitre'.$_GET['table'];
echo "<p>Table : ".$table." Titre : ".$titre."</p>\n";
}
mysql_select_db($table,$link);
if ($_GET['Idmax']>0) {
$requete = "DELETE FROM ".$table." WHERE `id` > ".abs($_GET['Idmax']);
if (!$rep=mysql_query($requete, $link)) {
echo "<p>Requête : ".$requete."</p>";
echo "<p>Echec !\n".mysql_error()."</p>";exit;}
echo "<p>Requête : ".$requete."</p>\n";
echo "<p>".$rep."</p>\n";
echo "<p>Efface Id >".$_GET['Idmax']."</p>\n";
}
if ($_GET['Idmin']>0) {
$requete = "DELETE FROM ".$table." WHERE `id` < ".abs($_GET['Idmin']);
if (!mysql_query($requete, $link)) {
echo "<p>Requête : ".$requete."</p>";
echo "<p>Echec !\n".mysql_error()."</p>";exit;}
echo "<p>Requête : ".$requete."</p>\n";
echo "<p>Efface Id <".$_GET['Idmin']."</p>\n";
}
mysql_close($link);
?>
</body>
</html>