par
nico44530 » 03 déc. 2012, 07:39
Bonjour,
J'ai un morceau de code qui fonctionne très bien, mais qui prend beaucoup de place, je voudrais savoir si on peut l'alléger.
C'est une simple requête de derniers membres inscrits avec la date en format : 03 Décembre 2012
Voici le code :
<?php
$sql = connect_sql();
$query = mysql_query('SELECT id, nom, prenom, temps FROM wa_communaute ORDER BY temps');
if ($query) {
while ($result = mysql_fetch_object($query)) {
$prenom = $result->prenom;
$nom = $result->nom;
$temps = $result->temps;
$id = $result->id;
$adresse_image = $sexe ==1 ? '../images/upload/homme.png' : '../images/upload/femme.png';
$filename = ''.$_SERVER["DOCUMENT_ROOT"].'/images/upload/'.$id.'.png';
if (file_exists($filename)) { ?>
<div class="content-mur">
<a href="<?php echo $url_site; ?>/home/profil.php?id=<?php echo $id; ?>#!<?php echo htmlentities(ucfirst($prenom)); ?><?php echo htmlentities(ucfirst($nom)); ?>">
<img src="../images/upload/<?php echo $id; ?>.png" width="50" height="50" alt="" />
</a>
<a href="<?php echo $url_site; ?>/home/profil.php?id=<?php echo $id; ?>#!<?php echo htmlentities(ucfirst($prenom)); ?><?php echo htmlentities(ucfirst($nom)); ?>">
<?php echo htmlentities(ucfirst($prenom)); ?> <?php echo htmlentities(ucfirst($nom)); ?>
</a>
<p>a rejoint Web Astronomie</p>
<span class="infos">Inscrit le <?php echo date("d", strtotime($temps)); ?> <?php echo $Mois[date("n", strtotime($temps))]; ?> <?php echo date("Y", strtotime($temps)); ?> à <?php echo date("H:i", strtotime($temps)); ?></span>
</div>
<span class="drop-line-mur"></span>
<?php } else { ?>
<div class="content-mur">
<a href="<?php echo $url_site; ?>/home/profil.php?id=<?php echo $id; ?>#!<?php echo htmlentities(ucfirst($prenom)); ?><?php echo htmlentities(ucfirst($nom)); ?>">
<img src="<?php echo $adresse_image; ?>" width="50" height="50" alt="" />
</a>
<a href="<?php echo $url_site; ?>/home/profil.php?id=<?php echo $id; ?>#!<?php echo htmlentities(ucfirst($prenom)); ?><?php echo htmlentities(ucfirst($nom)); ?>">
<?php echo htmlentities(ucfirst($prenom)); ?> <?php echo htmlentities(ucfirst($nom)); ?>
</a>
<p>a rejoint Web Astronomie</p>
<span class="infos">Inscrit le <?php echo date("d", strtotime($temps)); ?> <?php echo $Mois[date("n", strtotime($temps))]; ?> <?php echo date("Y", strtotime($temps)); ?> à <?php echo date("H:i", strtotime($temps)); ?></span>
</div>
<span class="drop-line-mur"></span>
<?php } } }
mysql_close(); ?>
Merci d'avance
Bonjour,
J'ai un morceau de code qui fonctionne très bien, mais qui prend beaucoup de place, je voudrais savoir si on peut l'alléger.
C'est une simple requête de derniers membres inscrits avec la date en format : 03 Décembre 2012
Voici le code :
[php]
<?php
$sql = connect_sql();
$query = mysql_query('SELECT id, nom, prenom, temps FROM wa_communaute ORDER BY temps');
if ($query) {
while ($result = mysql_fetch_object($query)) {
$prenom = $result->prenom;
$nom = $result->nom;
$temps = $result->temps;
$id = $result->id;
$adresse_image = $sexe ==1 ? '../images/upload/homme.png' : '../images/upload/femme.png';
$filename = ''.$_SERVER["DOCUMENT_ROOT"].'/images/upload/'.$id.'.png';
if (file_exists($filename)) { ?>
<div class="content-mur">
<a href="<?php echo $url_site; ?>/home/profil.php?id=<?php echo $id; ?>#!<?php echo htmlentities(ucfirst($prenom)); ?><?php echo htmlentities(ucfirst($nom)); ?>">
<img src="../images/upload/<?php echo $id; ?>.png" width="50" height="50" alt="" />
</a>
<a href="<?php echo $url_site; ?>/home/profil.php?id=<?php echo $id; ?>#!<?php echo htmlentities(ucfirst($prenom)); ?><?php echo htmlentities(ucfirst($nom)); ?>">
<?php echo htmlentities(ucfirst($prenom)); ?> <?php echo htmlentities(ucfirst($nom)); ?>
</a>
<p>a rejoint Web Astronomie</p>
<span class="infos">Inscrit le <?php echo date("d", strtotime($temps)); ?> <?php echo $Mois[date("n", strtotime($temps))]; ?> <?php echo date("Y", strtotime($temps)); ?> à <?php echo date("H:i", strtotime($temps)); ?></span>
</div>
<span class="drop-line-mur"></span>
<?php } else { ?>
<div class="content-mur">
<a href="<?php echo $url_site; ?>/home/profil.php?id=<?php echo $id; ?>#!<?php echo htmlentities(ucfirst($prenom)); ?><?php echo htmlentities(ucfirst($nom)); ?>">
<img src="<?php echo $adresse_image; ?>" width="50" height="50" alt="" />
</a>
<a href="<?php echo $url_site; ?>/home/profil.php?id=<?php echo $id; ?>#!<?php echo htmlentities(ucfirst($prenom)); ?><?php echo htmlentities(ucfirst($nom)); ?>">
<?php echo htmlentities(ucfirst($prenom)); ?> <?php echo htmlentities(ucfirst($nom)); ?>
</a>
<p>a rejoint Web Astronomie</p>
<span class="infos">Inscrit le <?php echo date("d", strtotime($temps)); ?> <?php echo $Mois[date("n", strtotime($temps))]; ?> <?php echo date("Y", strtotime($temps)); ?> à <?php echo date("H:i", strtotime($temps)); ?></span>
</div>
<span class="drop-line-mur"></span>
<?php } } }
mysql_close(); ?>
[/php]
Merci d'avance