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
|
<?php
session_start();
mysql_connect("localhost", "root", "mdp") or die(mysql_error());
mysql_select_db("ma base de données qui existe") or die(mysql_error());
?>
<html>
<head>
<title>Apprendre informatique - Administration : voir les news</title>
<link rel="shortcut icon" href="/images/logo.jpg" type="image/x-icon" />
<link rel="stylesheet" media="screen"
type="text/css" title="Design" href="../style.css" />
</head>
<?php
include("../haut-type.php");
?>
<table class="avanttexte" border="0" cellpadding="0" cellspacing="0"><!--table12-->
<tr>
<td><p class="title" style="margin-top: 11px;"><img src="/images/03.gif" alt="img" width="13" height="12"> <a href="../admin">Admin</a> >> Voir les news</td>
</tr>
</table><!--fintable12-->
<div class="normal2">
<h1>News dans la base de données :</h1>
<br /><br />
<?php
$retour = mysql_query("SELECT COUNT(*) AS nbre_entrees FROM news") or die(mysql_error());
$donnees = mysql_fetch_array($retour);
echo'<center>Il y a <b>'.$donnees['nbre_entrees'].'</b> news en tout.</center><br /><br /><br /><br /><br />';
if (isset($_GET['action']) && isset($_GET['id'])) //si oui, ça veut dire que on a cliqué sur 'supprimer'
{
if ($_GET['action'] == 'supprimer')
{
$id = $_GET['id'] ;
mysql_query("DELETE FROM news WHERE id = '$id'") or die(mysql_error()); //donc on supprime
echo'<br /><br /><center>La news a bien été supprimée.<br /><a href="voir-news.php">Retour</a></center>';
}
}
else
{
?>
<?php
$reponse = mysql_query("SELECT * FROM news ORDER BY id DESC"); // Requête SQL
// On fait une boucle pour lister tout ce que contient la table :
while ($donnees = mysql_fetch_array($reponse) )
{
?>
<div class="normal2">
<table class="membre">
<tr class="thmembre"> <td class="tdmembre"><?php echo $donnees['id'] ?></td></tr>
<tr class="thmembre"><td class="tdmembre"><?php echo $donnees['categorie'] ?></td></tr>
<tr class="thmembre"><td class="tdmembre"><?php echo $donnees['corps'] ?></td></tr>
</table><br /><a class="blanc" href="voir-news.php?action=supprimer&id=<?php echo $donnees['id'] ?>">Supprimer</a><br />
<a class="blanc" href="modifier-news.php?id=<?php echo $donnees['id']?>&categorie=<?php echo $donnees['categorie'] ?>">Modifier</a><hr>
</div></div>
<?php
}
}
?>
<?php
include("../bas.php");
?> |
Partager