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
| <?php
echo'<fieldset>';
?>
<style>
table{
margin-left:2px;
margin-right:2px;
text-align:center;
border:0px solid #fff;
}
.prem{
background-color:#efefef;
}
.classe1 {
background:#eeeeee;
}
.classe2 {
background:#dddddd;
}
</style>
<?php
// on se connecte à la base de données
include('../connexion.php');
mysql_connect("$nom_du_serveur","$nom_utilisateur","$passe");
mysql_select_db("$nom_de_la_base") or die('Impossible de sélectionner une base de donnée. Assurez vous d\'avoir correctement remplit les données du fichier connexion_bd.php.');
//On selectionne les données
$result = mysql_query('SELECT id,nom_annonce FROM annonces ORDER BY id ASC LIMIT 5');
//On voit si il y a quelque chose. Si il n'y a rien, on affiche un message
if(mysql_num_rows($result) == 0)
{
echo '<div class="cadre"><p>Aucune annonces pour le moment! <b>>><a title="Ajouter une catégorie" href="ajouter-annonces.php">Ajouter une annonce</a></b></p> </div>';
}
//Si il y a quelque chose, on affiche nos données
else
{
echo '<table style="width: 100%;" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="background-color: rgb(192, 192, 192); text-align: left;">Annonces</td> <td style="background-color: rgb(192, 192, 192); text-align: left;">Modifier</td> <td style="background-color: rgb(192, 192, 192); text-align: left;">Supprimer</td> </tr>';
while($affiche = mysql_fetch_array($result))
{
//On calcul le nombre d'article dans chaque catégorie
$calcul=$affiche['id'];
$result1 = mysql_query("SELECT id FROM annonces WHERE id=$calcul");
$total = mysql_num_rows($result1);
//Fin du calcul
echo '<tr class="prem '.( ($i % 2 == 0) ? 'classe1' : 'classe2' ).'"><td><a style="text-decoration:none" href="voir-annonces.php?id='.$affiche['id'].'"><font color="chocolate"/>'.$affiche['nom_annonce'].'</font></a></td> <td><a style="text-decoration:none" href="modifier-annonces.php?id='.$affiche['id'].'"><font color="chocolate"/><img src="images/modifier.png" alt="Modifier"/></font></a></td> <td><a style="text-decoration:none" href="supprimer-annonces.php?id='.$affiche['id'].'"><font color="chocolate"/><img src="images/supprimer. png" alt="Supprimer"/></font></a></td></tr>';
$i++;
}
echo '</tbody></table>';
//On ferme else
}
?>
<br>
<?php
if (mysql_num_rows($result1))
{
echo'<b><a href="ajouter-annonces.php">Ajouter une annonce</a></b>';
}
?>
<?php
echo'</fieldset>';
?> |