mon soucis est le suivant
sur ma page liste.php j'ai mon tableau de client avec suppression, modif etc..
avant de vouloir supprimer un client via un script java tout fonctionnai nickel
vous pouvez me venir en aide svp?
voici mon code (je vous ai mis que ce qui concerne ma demande)
ps: ne faite pas attention aux requêtes je vais les mettre en pdo.
Code : Tout sélectionner
<?php
if(isset($_GET["action"]) && $_GET["action"]=="suppr")
{
$sql="DELETE FROM registre_client WHERE client_id=$_GET[client_id]";
mysql_query($sql) or die(mysql_error());
}
echo'<section><h2>liste client</h2>
<center><table><tr><td>Trier par ordre: </td>
<td><a href="liste.php?orderby=asc"><input type="button" value="Croissant"></a></td>
<td><a href="liste.php?orderby=desc"><input type="button" value="Décroissant"</a></td></tr></table></center>
<center><table id="tableau">
<thead>
<tr>
<th>Fiche</th>
<th>Numéro client</th>
<th>Nom</br>Prenom</th>
<th>Categorie</th>
<th>Adresse</br>Cp Ville</th>
<th>Compte-rendu</th>
<th>Historique</br>de la fiche</th>';
if($lvl=='admin')
{
echo'<th>supprimer</th>';
}
echo'<th>modifier</th>
</tr></thead>';
$sql='SELECT * FROM registre_client';
$req = mysql_query($sql)or die(mysql_error());
while($data = mysql_fetch_assoc($req))
{
echo '<tbody><tr>
<td><a href="fiche-client.php?client_id='.$data["client_id"].'&action=consulter"><img src="./images/dossier.png"></a></td>
<td>'.$data['client_id'].'</td>
<td>'.$data["client_nom"].'</br>'.$data["client_prenom"].'</td>
<td>'.$data["client_cat"].'</td>
<td>'.$data["client_adresse"].'</br>'.$data["client_cp"].' '.$data["client_ville"].'</td>
<td><a href="compte-rendu.php?client_id='.$data["client_id"].'&action=insert-c-rendu">compte-rendu</a></td>
<td><a href="historique-client.php?client_id='.$data["client_id"].'&action=historique"><input type="button" value="GO"></a></td>';
if($lvl=='admin')
{
//echo'<td><a href="liste.php?client_id='.$data["client_id"].'&action=suppr"><img src="./images/supprimer.gif"></a></td>';
echo'<td><a href="" onClick="confirme('.$data["client_id"].')"><img src="./images/supprimer.gif"></a></td>';
}
echo'<td><a href="./nouveau-client.php?client_id='.$data["client_id"].'&action=modif"><img src="./images/modifier.gif"></a></td>
</tr></tbody>';
}
echo '</table></center></br>
</section></br>
?>
<script language="javascript">
function confirme(client_id)
{
var confirmation = confirm( "Voulez vous vraiment supprimer ce client ?" );
if(confirmation)
{
document.location.href="liste.php?client_id="+client_id"&action=suppr";
}
else
{
alert("On ne peu pas faire ça!");
}
}
</script>