i woud like to have the name of the topic instead an id number.
like that=>http://www.class-rnb.com/2011/09/21/lady-kaylani-gangsta-clip/
instead of http://www.http://hiphop509.net/?p=619
here the code of the function
<?php session_start();
?>
<?php
function trimBody($theText, $lmt=200, $s_chr="\n", $s_cnt=2) {
$pos = 0;
$trimmed = FALSE;
for ($i = 1; $i <= $s_cnt; $i++) {
if ($tmp = strpos($theText, $s_chr, $pos+1)) {
$pos = $tmp;
$trimmed = TRUE;
} else {
$pos = strlen($theText) - 1;
$trimmed = FALSE;
break;
}
}
$theText = substr($theText, 0, $pos);
if (strlen($theText) > $lmt) {
$theText = substr($theText, 0, $lmt);
$theText = substr($theText, 0, strrpos($theText,' '));
$trimmed = TRUE;
}
if ($trimmed) $theText .= '...';
return $theText;
}
function outputStory($article, $only_snippet=FALSE) {
global $conn;
if ($article) {
$sql = "SELECT ar.*, usr.name " .
"FROM cms_articles ar " .
"LEFT OUTER JOIN cms_users usr " .
"ON ar.author_id = usr.user_id " .
"WHERE ar.article_id = " . intval($article);
$result = mysql_query($sql,$conn);
if ($row = mysql_fetch_array($result)) {
$title = $row['images'] . $images = $row['title'] . "<br />";
if ($row['is_published'] == 1) {
//echo date("F j, Y",strtotime($row['date_published']));
} else {
echo "not yet published";
}
if ($only_snippet) {
$body = trimBody($row['body']);
$article_id = intval($row['article_id']);
echo "<a href=\"http://www.hipkreyol.com/news/liatik.php?article=" .
intval($article_id) . "\">$title </a><br>";
} else {
echo "<p>\n";
echo nl2br($row['body']);
echo "</p>\n";
}
}
}
}
function showComments($article, $showLink=TRUE) {
global $conn;
if ($article) {
$sql = "SELECT is_published " .
"FROM cms_articles " .
"WHERE article_id=" . urlencode(intval($article)) ;
$result = mysql_query($sql,$conn)
or die('Paka jwenn commentaire; ' . mysql_error());
$row = mysql_fetch_array($result);
$is_published = $row['is_published'];
$sql = "SELECT * " .
"FROM cms_comments " .
"WHERE article_id=" . $article .
" ORDER BY comment_date DESC LIMIT 40";
$result = mysql_query($sql, $conn)
or die('Pa ka jwenn commentaire; ' . mysql_error());
if ($showLink) {
echo " <a href=\"commentaires.php?article=" . intval($_GET['article']) .
"\">Faire un commentaire</a>" . "<br />";
if ( $is_published) {
echo "<h4>" . mysql_num_rows($result) . " Commentaire(s)";
}
echo "</h4>\n";
}
if (mysql_num_rows($result)) {
while ($row = mysql_fetch_array($result)) {
echo "<p style=font-size:14>" .
nl2br(htmlspecialchars($row['comment'])) . "<br/>" . "<strong>" . htmlspecialchars($row['cms_nom']) . "</strong>" .
"\n</p>\n";
}
echo "<p style=font-size:14>" . " " . "  " ."<i style='font-size:10px>" ."Le" . " " .
htmlspecialchars(date('d/m/Y H:h:s', strtotime($row['comment_date']))) . "</i>". "</p>"
;
}
echo "<br>\n";
}
}
function trimBody_search($theText, $lmt=200, $s_chr="\n", $s_cnt=2) {
$pos = 0;
$trimmed = FALSE;
for ($i = 1; $i <= $s_cnt; $i++) {
if ($tmp = strpos($theText, $s_chr, $pos+1)) {
$pos = $tmp;
$trimmed = TRUE;
} else {
$pos = strlen($theText) - 1;
$trimmed = FALSE;
break;
}
}
$theText = substr($theText, 0, $pos);
if (strlen($theText) > $lmt) {
$theText = substr($theText, 0, $lmt);
$theText = substr($theText, 0, strrpos($theText,' '));
$trimmed = TRUE;
}
if ($trimmed) $theText .= '...';
return $theText;
}
function outputStory_search($article, $only_snippet=FALSE) {
global $conn;
if ($article) {
$sql = "SELECT ar.*, usr.name " .
"FROM cms_articles ar " .
"LEFT OUTER JOIN cms_users usr " .
"ON ar.author_id = usr.user_id " .
"WHERE ar.article_id = " . intval($article);
$result = mysql_query($sql,$conn);
if ($row = mysql_fetch_array($result)) {
$title = $row['title'] . "<br />";
if ($row['is_published'] == 1) {
//echo date("F j, Y",strtotime($row['date_published']));
} else {
echo "not yet published";
}
if ($only_snippet) {
// $body = trimBody_search(htmlspecialchars($row['body']));
$article_id = intval($row['article_id']);
echo "<a href=\"lyrics/liatik.php?article=" .
intval($article_id) . "\">$title </a><br>";
} else {
echo $row['title'];
}
}
}
}
function trimBodynews($theText, $lmt=300, $s_chr="\n", $s_cnt=2) {
$pos = 0;
$trimmed = FALSE;
for ($i = 1; $i <= $s_cnt; $i++) {
if ($tmp = strpos($theText, $s_chr, $pos+1)) {
$pos = $tmp;
$trimmed = TRUE;
} else {
$pos = strlen($theText) - 1;
$trimmed = FALSE;
break;
}
}
$theText = substr($theText, 0, $pos);
if (strlen($theText) > $lmt) {
$theText = substr($theText, 0, $lmt);
$theText = substr($theText, 0, strrpos($theText,' '));
$trimmed = TRUE;
}
if ($trimmed) $theText .= '...';
return $theText;
}
function outputStorynews($article, $only_snippet=FALSE) {
global $conn;
if ($article) {
$sql = "SELECT ar.*, usr.name " .
"FROM cms_articles ar " .
"LEFT OUTER JOIN cms_users usr " .
"ON ar.author_id = usr.user_id " .
"WHERE ar.article_id = " . intval($article);
$result = mysql_query($sql,$conn);
if ($row = mysql_fetch_array($result)) {
$title = $row['title'] . "<br />";
if ($row['is_published'] == 1) {
echo "Le" . " " . date('d/m/Y',strtotime($row['date_published'])) . "<br />";
} else {
echo "not yet published";
}
if ($only_snippet) {
;
$body = trimBodynews(stripslashes($row['body']));
echo "<a href=\"http://hipkreyol.com/news/liatik.php?article=" .
urlencode(intval($row['article_id'])) . "\">$title </a><br>";
} else {
echo "<p>\n";
echo nl2br (mysql_real_escape_string((htmlspecialchars($row['body']))));
echo "</p>\n";
}
}
}
}