Code Snippet: Display news items, anywhere


fienieg

I made very rough code, that makes a listing of a specific group(id)
With the option of setting a "max results", and order them by date added. etc..

Just read the code, play with it. Refine it, restyle it.

Have fun..


<!-- NEWS READER -->
<?php
$group 
0// Specify the Group&#40;id&#41; you want to read the news from

global $database;

$query "SELECT post_id,title,group_id,link 
  FROM "
.TABLE_PREFIX."mod_news_posts
          WHERE group_id = 
$group
          ORDER BY posted_when DESC 
  LIMIT 0, 5;"
// This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10.
  // The first number defines the starting point, and the second the max/end of the results
$error mysql_error&#40;&#41;;
if &#40;!$result = mysql_query&#40;$query&#41;&#41; &#123;
    
print "$error";
exit;
&#125;

while&#40;$data = mysql_fetch_object&#40;$result&#41;&#41;&#123;
  
$title $data->title;
  
$id $data->post_id;
  
$link $data->link?>

<p>
<a href="<?php echo WB_URL?><?php echo $link ?><?php echo PAGE_EXTENSION?>"><?php echo $title?></a>
</p>
<?php
&
#125;
?>

<!-- END NEWS READER -->