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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
<-- page affichage -->
<?php
//-----------------------------------------------------
// Vérification 1 : est-ce qu'on veut poster une fiche ?
//-----------------------------------------------------
if(isset($_POST['id_cat']))
{
$id_cat = addslashes($_POST['id_cat']);
$categorie = addslashes($_POST['categorie']);
$id_niveau = addslashes($_POST['id_niveau']);
$niveau = addslashes($_POST['niveau']);
$id_auteur= addslashes($_POST['id_auteur']);
$titre = addslashes($_POST['titre']);
$description= addslashes($_POST['description']);
$paragraphe1 = addslashes($_POST['paragraphe1']);
if ($_POST['id_cat'] == 0)
{
// Ce n'est pas une modification, on crée une nouvelle entrée dans la table "fiches_infos"
//mysql_query("INSERT INTO fiches_infos VALUES('', '" . time() . "', '" . $titre. "', '" . $description . "', '" . $paragraphe1 . "', '" . $id_cat . "', '" . $id_auteur . "', '" . $id_niveau . "')");
mysql_query("INSERT INTO fiches_infos VALUES('', '" . $titre. "', '" . $description . "', '" . $paragraphe1 . "', '" . $id_cat . "', '" . $id_auteur . "', '" . $id_niveau . "')");
}
else
{
// On protège la variable "id_fiche" pour éviter une faille SQL
$_POST['id_cat'] = addslashes($_POST['id_cat']);
// C'est une modification, on met juste à jour
mysql_query("UPDATE fiches_infos SET titre='" . $titre . "', description='" . $description . "', paragraphe1='" . $paragraphe1 . "', id_cat='" . $id_cat . "', id_auteur='" . $id_auteur . "', id_niveau='" . $id_niveau . "' WHERE id_cat='" . $_POST['id_cat'] . "'");
}
}
//--------------------------------------------------------
// Vérification 2 : est-ce qu'on veut supprimer une fiche ?
//--------------------------------------------------------
if (isset($_GET['supprimer_fiche'])) // Si on demande de supprimer une fiche
{
// Alors on supprime le lien correspondant
// On protège la variable "id_fiche" pour éviter une faille SQL
$_GET['supprimer_fiche'] = addslashes($_GET['supprimer_fiche']);
mysql_query('DELETE FROM fiches_infos WHERE id=\'' . $_GET['supprimer_fiche'] . '\'');
}
?>
<table cellpadding="1" cellspacing="1">
<tr bgcolor="#DDDDDD">
<th></th>
<th></th>
<th height="20"><span class="texte_courant_gris_b"><?php echo '<a href="liste_fiche.php?rangerpar=fiches_infos.id_cat" title="ranger">' ?>id_cat</a></span></th>
<th height="20"><span class="texte_courant_gris_b"><?php echo '<a href="liste_fiche.php?rangerpar=fiches_infos.id_auteur" title="ranger">' ?>id_auteur</a></span></th>
<th height="20"><span class="texte_courant_gris_b"><?php echo '<a href="liste_fiche.php?rangerpar=fiches_cat.categorie" title="ranger">' ?>categorie</a></span></th>
<th height="20"><span class="texte_courant_gris_b"><?php echo '<a href="liste_fiche.php?rangerpar=fiches_niveau.niveau" title="ranger">' ?>niveau</a></span></th>
<th height="20"><span class="texte_courant_gris_b"><?php echo '<a href="liste_fiche.php?rangerpar=fiches_auteur.nom" title="ranger">' ?>Auteur</a></span></th>
<th height="20"><span class="texte_courant_gris_b"><?php echo '<a href="liste_fiche.php?rangerpar=titre" title="ranger">' ?>titre</a></span></th>
<th height="20"><span class="texte_courant_gris_b"><?php echo '<a href="liste_fiche.php?rangerpar=description" title="ranger">' ?>description</a></span></th>
<th height="20"><span class="texte_courant_gris_b"><?php echo '<a href="liste_fiche.php?rangerpar=paragraphe1" title="ranger">' ?>paraph1</a></span></th>
</tr>
<?php
if(isset($_GET['rangerpar'])) $rangerpar = $_GET['rangerpar'];
else $rangerpar = "id";
$myrequetecheri = 'SELECT fiches_niveau.niveau, fiches_niveau.id_niveau, fiches_cat.categorie, fiches_cat.id_cat, fiches_infos.id_cat, fiches_infos.id_auteur, fiches_infos.id, fiches_infos.titre, fiches_infos.description, fiches_infos.paragraphe1, fiches_auteur.id_auteur, fiches_auteur.nom, fiches_auteur.prenom, fiches_auteur.email, fiches_auteur.url FROM fiches_infos, fiches_auteur, fiches_niveau, fiches_cat WHERE fiches_infos.id_auteur = fiches_auteur.id_auteur ORDER BY ' . $rangerpar;
//$myrequetecheri = 'SELECT fiches_niveau.niveau, fiches_niveau.id_niveau, fiches_cat.categorie, fiches_cat.id_fiche, fiches_infos.id_fiche, fiches_infos.id_auteur, fiches_infos.id, fiches_infos.titre, fiches_infos.description, fiches_infos.paragraphe1, fiches_auteur.nom, fiches_auteur.prenom, fiches_auteur.email, fiches_auteur.url, fiches_auteur.nom FROM fiches_infos, fiches_auteur, fiches_niveau, fiches_cat WHERE fiches_infos.id_auteur = fiches_auteur.id_auteur AND fiches_infos.id_niveau = fiches_niveau.id_niveau AND fiches_infos.id_fiche = fiches_cat.id_fiche ORDER BY ' . $rangerpar;
$retour = mysql_query($myrequetecheri);
while ($donnees = mysql_fetch_array($retour)) // On fait une boucle pour lister les liens
{
?>
<tr bgcolor="#FFFFFF">
<th><?php echo '<a href="rediger_fiche.php?modifier_fiche=' . $donnees['id'] . '" title="modifier">'; ?><img src="img/picto_modifier.gif" border="0"></a></th>
<th><?php echo '<a href="liste_fiche.php?supprimer_fiche=' . $donnees['id'] . '" title="supprimer">'; ?><img src="img/picto_supprimer.gif" border="0"></a></th>
<th><span class="texte_courant_gris"><?php echo stripslashes($donnees['id_cat']); ?></span></th>
<th><span class="texte_courant_gris"><?php echo stripslashes($donnees['id_auteur']); ?></span></th>
<th><span class="texte_courant_gris"><?php echo stripslashes($donnees['categorie']); ?></span></th>
<th><span class="texte_courant_gris"><?php echo stripslashes($donnees['niveau']); ?></span></th>
<th><span class="texte_courant_gris"><?php echo stripslashes($donnees['nom']); ?></span></th>
<th><span class="texte_courant_gris"><?php echo stripslashes($donnees['titre']); ?></span></th>
<th><span class="texte_courant_gris"><?php echo stripslashes($donnees['description']); ?></span></th>
<th><span class="texte_courant_gris"><?php echo stripslashes($donnees['paragraphe1']); ?></span></th>
</tr>
<?php
}
// on ferme la connexion à mysql
mysql_close();
?> |
Partager