Bonjour à tous, je me présent, dimitri54g !
Je suis le créateur de Visual Development : http://www.visualdevelopment.fr
Je ne sais pas comment expliquer mais je veux faire un code, j'espère que vous comprendrez
http://pastebin.com/7BMNmdtg
$articleData = null;
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
$id = intval($_GET['id']); // On choisis un article selon le paramètre $_GET
$getNews = dbquery("SELECT * FROM site_news WHERE id = '" . $id . "' LIMIT 1");
if (mysql_num_rows($getNews) > 0)
{
$articleData = mysql_fetch_assoc($getNews);
}
}
else
{
$getNews = dbquery("SELECT * FROM site_news ORDER BY timestamp DESC LIMIT 1");
if (mysql_num_rows($getNews) > 0)
{
$articleData = mysql_fetch_assoc($getNews);
}
}
$tpl->Init(); // Initiation de la page
$tpl->AddGeneric('head-init');
$tpl->AddIncludeFile(new IncludeFile('text/css', WWW . '/style.css', 'stylesheet'));
$tpl->WriteIncludeFiles();
$tpl->AddGeneric('head-bottom');
$tpl->AddGeneric('barre'); // Menu + Login
$newslist = new Template('comp-newlist'); // Liste des articles
$article = new Template('comp-newsarticle');
$newslist->SetParam('mode', 'recent');
if ($articleData != null)
{
$newslist->SetParam('name', $articleData['title']);
$newslist->SetParam('id_article', $articleData['id']);
ça suffira ?/*for ($i = 1; $i <= $value; $i++){
if ($i != $id_article) {
echo'<a href="' . WWW . '/article.php?id=' . $ID_db . '">' . $Titre . '</a> ';
}
else { echo"<li class='new'>" . $name . "</li>"; }
}*/
if ($mode == 'recent')
{
for ($i = 0; $i < 6; $i++)
{
$sectionName = '';
$sectionCutoffMax = 0;
$sectionCutoffMin = 0;
switch ($i)
{
case 0:
$sectionName = 'Aujourd\'hui';
$sectionCutoffMax = time();
$sectionCutoffMin = time() - 86400;
break;
case 1:
$sectionName = 'Hier';
$sectionCutoffMax = time() - 86400;
$sectionCutoffMin = time() - 172800;
break;
case 2:
$sectionName = 'Ce week-end';
$sectionCutoffMax = time() - 172800;
$sectionCutoffMin = time() - 604800;
break;
case 3:
$sectionName = 'La semaine dernière';
$sectionCutoffMax = time() - 604800;
$sectionCutoffMin = time() - 1209600;
break;
case 4:
$sectionName = 'Ce mois-ci';
$sectionCutoffMax = time() - 1209600;
$sectionCutoffMin = time() - 2592000;
break;
case 5:
$sectionName = 'Le mois dernièr';
$sectionCutoffMax = time() - 2592000;
$sectionCutoffMin = time() - 5184000;
break;
}
$q = "SELECT * FROM site_news WHERE timestamp >= " . $sectionCutoffMin . " AND timestamp <= " . $sectionCutoffMax . " ORDER BY timestamp DESC";
$getArticles = dbquery($q);
if (mysql_num_rows($getArticles) > 0)
{
echo '<h2>' . $sectionName . '</h2>
<ul>';
while ($a = mysql_fetch_assoc($getArticles))
{
echo '<li class="new">
<a href="%www%/article.php?id=' . $a['id'] . '" class="article-' . $a['id'] . '">' . clean(decode($a['title'])) . ' »</a>
</li>';
}
echo '</ul>';
}
}
}
<?php
sql = 'SELECT * FROM site_news WHERE timestamp >= " . $sectionCutoffMin . " AND timestamp <= " . $sectionCutoffMax . " and id<> '.$_GET['id'].'ORDER BY timestamp DESC';
// ou
sql = 'SELECT * FROM site_news WHERE timestamp between ' . $sectionCutoffMin . ' AND ' . $sectionCutoffMax . " and id<> '.$_GET['id'].'ORDER BY timestamp DESC';
?>
si bien entendu tu a dans l'url id=456 où 456 est la clef primaire de la table en question (que j'ai appelé ici "id" mais c'est seulement par "habitude" et abut de langage).
echo '<li class="new">
<a href="%www%/article.php?id=' . $a['id'] . '" class="article-' . $a['id'] . '">' . clean(decode($a['title'])) . ' »</a>
</li>';
A mon avis, c'est dans cette partie qu'il faut intervenir pour faire un affichage sans le lien dans le cas ou $a['id'] correspond à l'article en cours if (isset($GLOBALS["id_article"])
{
$id = $GLOBALS["id_article"];
}
else
{
$id = 0;
}
while ($a = mysql_fetch_assoc($getArticles))
{
if ($a['id']==$id)
{
echo '<li class="new">' . clean(decode($a['title'])) . ' »</li>';
}
else
{
echo '<li class="new">
<a href="%www%/article.php?id=' . $a['id'] . '" class="article-' . $a['id'] . '">' . clean(decode($a['title'])) . ' »</a>
</li>';
}
}
echo '</ul>';
Il faut cependant définir $GLOBALS["id_article"] dans la page qui affiche l'article.if ($id_article > 0)
{
$id = $id_article;
}
while ($a = mysql_fetch_assoc($getArticles))
{
if ($a['id']==$id)
{
echo '<li class="article">' . clean(decode($a['title'])) . ' »</li>';
}
else
{
echo '<li class="new">
<a href="%www%/article.php?id=' . $a['id'] . '" class="article-' . $a['id'] . '">' . clean(decode($a['title'])) . ' »</a>
</li>';
}
}