Récupérer une variable pour l'insérer en <title>
Bonsoir,
Voila j'utilise un bout de code afin d'afin une news par page via son ID dans ma base de donnée dont voici le code (faites pas gaffe aux nombreux \n, ils sont la pour afficher un code source propre, c'est plus simple pour moi rechercher un truc dedans parfois)
Code:
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
|
<?php
$titre='News en détails';
$description='Les dernières news sur l\'actualité de Blind Guardian';
include('../includes/header.inc.php');
echo' <div class="news-left">
<h1>News :</h1>';
echo "\n ";
function cleanText($intext) {
return utf8_encode($intext);
}
$db_link = @mysql_connect($host,$login,$pass);
mysql_select_db($base);
$newsId= ( isset($_GET["id"])) ? $_GET['id'] : FALSE;
if ( is_numeric($newsId)) {
$sql = 'SELECT * FROM news WHERE newsId = ' . $newsId;
$rc = mysql_query($sql);
if ( $data = mysql_fetch_assoc($rc) ) {
$data['news'] = str_replace("\n"," <br />", $data['news']);
echo "<h2>";
echo date ( 'd/m/Y' , $data['time'] );
echo " - ";
echo ( cleanText($data['titre']) );
echo "</h2>";
echo "\n ";
print ''.cleanText($data['news']).'';
echo "\n ";
if (strlen($data['url_forum']) > 0) {
print '<div class="forum-news">(<a href="'.$data['url_forum'].'" title="'.cleanText($data['titre']).'">On en parle sur le forum</a>)</div>';
}
echo "<br />\n <br />\n <br />";
echo "\n ";
}
else {
$sql = 'SELECT * FROM news ORDER BY newsId DESC LIMIT 0,1';
$rc = mysql_query($sql);
$data = mysql_fetch_assoc($rc);
$data['news'] = str_replace("\n"," <br />", $data['news']);
echo "<h2>";
echo date ( 'd/m/Y' , $data['time'] );
echo " - ";
echo ( cleanText($data['titre']) );
echo "</h2>";
echo "\n ";
print ''.cleanText($data['news']).'';
echo "\n ";
if (strlen($data['url_forum']) > 0) {
print '<div class="forum-news">(<a href="'.$data['url_forum'].'" title="'.cleanText($data['titre']).'">On en parle sur le forum</a>)</div>';
}
echo "<br />\n <br />\n <br />";
echo "\n ";
}
}
else {
$sql = 'SELECT * FROM news ORDER BY newsId DESC LIMIT 0,1';
$rc = mysql_query($sql);
$data = mysql_fetch_assoc($rc);
$data['news'] = str_replace("\n"," <br />", $data['news']);
echo "<h2>";
echo date ( 'd/m/Y' , $data['time'] );
echo " - ";
echo ( cleanText($data['titre']) );
echo "</h2>";
echo "\n ";
print ''.cleanText($data['news']).'';
echo "\n ";
if (strlen($data['url_forum']) > 0) {
print '<div class="forum-news">(<a href="'.$data['url_forum'].'" title="'.cleanText($data['titre']).'">On en parle sur le forum</a>)</div>';
}
echo "<br />\n <br />\n <br />";
echo "\n ";
}
mysql_close();
echo'<div class="archives-news">- <a href="/html/archives-news-page1.php" title="Archives Des News">Archives Des News</a> -</div>';
echo'</div>
<div class="news-right">';
echo "\n";
include('../includes/news-right.inc.php');
echo'</div>';
echo "\n";
include('../includes/footer.inc.php');
?> |
Le "$titre='News en détails'; " étant la pour remplis la balise <title> du fichier "/includes/header.php", celle ci n'est pas dynamique et reste donc la même quelle que soit la news affichées.
Dans le but d'un meilleur référencement j'aimerai afficher le titre de la news contenu dans le champ "titre" de la table "news".
Comment pourrais-je faire ?
Merci de vos réponses :)