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
|
// suppression
if(isset($_POST['sub_form']))
{
$sql = "DELETE FROM rat WHERE id_rat = ".$_POST['supp'];
$res = mysql_query($sql) or die (mysql_error());
echo "rat supprimé";
}
echo "<br>";
echo "<br>";
$SQL = 'SELECT * FROM rat';
$req = mysql_query($SQL) or die('Erreur SQL !<br>'.$SQL.'<br>'.mysql_error());
echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
while($data = mysql_fetch_assoc($req))
{
echo "Identifiant : "."<input type =texte name=ok value=".$data['id_rat']."><br>" ;
echo "Nom : "."<input type =texte name=ok value=".$data['nom_rat'].">" ;
echo "Sexe : "."<input type =texte name=ok value=".$data['sexe_rat'].">" ;
echo "Poids : "."<input type =texte name=ok value=".$data['poids_rat'].">" ;
echo "Age : "."<input type =texte name=ok value=".$data['age_rat'].">" ;
echo "Couleur : "."<input type =texte name=ok value=".$data['couleur_rat'].">";
echo "<input type=\"radio\" name=\"supp\" value=\"{$data['id_rat']}\" />"."<br><br>";
}
// modifier
if(isset($_POST['sub_form2']))
{
$sql2 = "UPDATE rat SET nom_rat = '".$data['nom_rat']."', sexe_rat = '".$data['sexe_rat']."', poids_rat = '".$data['poids_rat']."', age_rat = '".$data['age_rat']."', couleur_rat = '".$data['couleur_rat']."' WHERE id_rat = ".$_POST['supp'];
$res2 = mysql_query($sql2) or die (mysql_error());
echo "rat modifié";
}
echo "<input type=\"submit\" name=\"sub_form\" value=\"supprimer\" />";
echo "<input type=\"submit\" name=\"sub_form2\" value=\"modifier\" />";
echo "</form>";
echo "<a href = nouveaurat.php>ajout d un rat</a>";
echo "</form>"; |
Partager