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
|
<?php
define('CONF_ONLY','1');
include('/news/conf/config.php');
@ $db = mysql_pconnect(DB_HOST,DB_USER,DB_PASS);
if(!$db) { echo 'Erreur de connexion'; exit; }
mysql_select_db(DB_DBASE);
$query =
' SELECT post_titre,post_titre_url,post_chapo,post_content,cat_id
FROM '.DB_PREFIX.'post
WHERE cat_id = 2
ORDER BY post_id DESC LIMIT 3';
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo '<ul id=divune>';
for($i = 0 ; $i < $num_results ; $i++)
{
$row = mysql_fetch_array($result);
$date = explode(' ',$row['post_dt']);
$date_slash = str_replace('-',' ',$date[0]);
$titre = $row['post_titre'] ;
$titre_court = $titre ;
$lg_max = 120; //nombre de caractère autoriser
if (strlen($titre_court) > $lg_max)
{
$titre_court = substr($titre_court, 0, $lg_max);
$last_space = strrpos($titre_court, " ");
$titre_court = substr($titre_court, 0, $last_space)."...";
}
echo '<li class="viole"><a href="/news/index.php?'.$date_slash.''
.$row['post_id'].''.$row['post_titre_url'].'" title="'
.$row['post_titre'].'"> '.$titre_court.' </a></li>';
}
echo '</ul>';
?> |
Partager