1
This code displays a listing of last news with date.
I want to do is that the news by topic
eg: the news of topic 1
I can do it?
PHP:
$myts =& MyTextSanitizer::getInstance();
$sql = "SELECT storyid, title, published, expired, counter FROM ".$xoopsDB->prefix("stories")." WHERE published < ".time()." AND published > 0 AND (expired = 0 OR expired > ".time().") ORDER BY created DESC";
$result = $xoopsDB->query($sql,5,0);
while ( $myrow = $xoopsDB->fetchArray($result) ) {
$news = array();
$title = $myts->makeTboxData4Show($myrow["title"]);
if ( !XOOPS_USE_MULTIBYTES ) {
if (strlen($myrow['title']) >= 100) {
$title = $myts->makeTboxData4Show(substr($myrow['title'],0,(100 -1)))."...";
}
}
$xoopsTpl-> append('news', array(
'title' => $title,
'id' => $myrow['storyid'],
'date' => formatTimestamp($myrow['published'],"s")
));
}
Template:
<{foreach item=i from=$news}>
<a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$i.id}>">
<{$i.title}>a> (<{$i.date}>)<br>
<{/foreach}>
example 1 (27 october)
Thank you
Translate: google