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
|
<?php
if (!empty($ancien_utilisateur)) {
@$db = new mysqli('localhost', 'julien', 'admin', 'web');
if(mysqli_connect_errno()) {
echo "Impossible de se connecter à la base de données.";
exit;
}
if (isset($_POST['supprimer'])) // test si on a cliquer sur un bouton
{
$idbouton = $_POST['supprimer'];
$sup= " DELETE FROM occasion WHERE id_occas='$idbouton'";
$supp = $db->query($sup);
}
$ma_requete = " SELECT * from occasion ";
$resultat = $db->query($ma_requete);
$nb_lig_resultat = $resultat->num_rows; ?>
<form name="form1" method="post" action="">
<?php
$j = 0;
for($i =0; $i < $nb_lig_resultat; $i++) {
$ligne = $resultat->fetch_assoc(); ?>
<tr
<?php
if($j % 2 == 0)
{
echo 'bgcolor="#DCDCDC"';
echo 'onmouseover="bgColor=\'lightyellow\';"';
echo 'onmouseout="bgColor=\'#DCDCDC\'" >'; }
else {
echo 'bgcolor="#F0F0F0"';
echo 'onmouseover="bgColor=\'lightyellow\';"';
echo 'onmouseout="bgColor=\'#F0F0F0\'" >'; }
?>
<td></td>
<td class="cellpty">
<?php echo stripslashes($ligne['marque_occas']) . '</td>'; ?>
<td class="cellpty">
<?php echo stripslashes($ligne['modele_occas']) . '</td>';?>
<td class="cellpty"><a href="" />
<?php echo stripslashes($ligne['version_occas']) . '</td>';?>
<td class="cellpty">
<?php echo stripslashes($ligne['annee_occas']) . '</td>';?>
<td class="cellpty">
<?php echo stripslashes($ligne['color_ext_occas']) . '</td>';?>
<td class="cellpty">
<?php echo stripslashes($ligne['km_occas']) . '</td>';?>
<td class="cellpty">
<?php echo stripslashes($ligne['energie_occas']) . '</td>';?>
<td class="cellpty">
<?php echo stripslashes($ligne['puissance_occas']) . '</td>';?>
<td class="cellpty"><strong>
<?php echo stripslashes($ligne['prix_occas']) . '</strong></td>';?>
<td> <input name="supprimer[]" type="checkbox" id="supprimer[]" value="<?php echo $ligne['id_occas']; ?>"></td> </td>
</tr>
<?php $j++ ?>
<?php }
?>
</table>
<input type="submit" name="Submit" value="supprimer">
</form>
<?php
if (!empty($_POST['supprimer'])) {
foreach ($_POST['supprimer'] as $cle) {
$Requete = "DELETE FROM `occasion` WHERE `id_occas`='$cle'";
$resRequete = mysql_query($Requete, 'localhost', 'julien', 'admin', 'web') or die(mysql_error());
}
}
$resultat->free();
$db->close(); ?>
<?php } else { ?> |
Partager