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
| <?php include('connexion.php');?>
<form id="form1" name="form1" method="post" action="vidage.php">
<p><em><strong>Séléctionnez les tables à vider</strong></em></p>
<?php
$sql = "show tables";
$resultat = mysql_query($sql);
while($line = mysql_fetch_row($resultat)){
echo ' <table width="200" border="0">
<tr>
<td>';
echo '<input type="checkbox" name="checkbox[]" id="checkbox" value="'.$line[0].'" /> Table '.$line[0];
echo '</td>
</tr>';
}
?>
<tr>
<td></td>
<td>
<input type="submit" name="valider" id="button" value="Vider" onclick="confirmer();" />
</label></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['checkbox'])){
$checkbox = $_POST['checkbox'];
for($i = 0; $i < count($checkbox); $i++){
$sql = "TRUNCATE TABLE " . $checkbox[$i];
$resultat = mysql_query($sql) or die(mysql_error());
}
}
?>
<script type="text/javascript">
function confirmer() {
return confirm('Voulez-vous vider la table?')
}
</script> |