I am new to drupal ,i have got a problem in the pagination.Hers is my code
drupal_add_css(drupal_get_path('module', 'news') .'/news.css', 'last', 'all', TRUE);
$breadcrumb = array();
$breadcrumb = array(l(t('Home'), ''), l(t('News'), 'client_news'));
drupal_set_breadcrumb($breadcrumb);

$news_content = '';
$limit = 5;
$query = "SELECT * FROM news";
$record_count = db_result(db_query("SELECT COUNT(*) FROM {news}"));
$result = pager_query($query,$limit,0,$record_count);

while($links = db_fetch_object($result)) {

$length_news = strlen(trim($links->news_desc));

if ($length_news > 300) {
$news_desc = substr($links->news_desc, 0, 300). '...';
} else {
$news_desc = $links->news_desc;
}

$status = ($links->is_active == 'Publish')?'Published':'Unpublished';

$news_content .= theme('news_display',
check_plain($links->news_title),
check_plain($news_desc),
l('More','news_detail/view/' . $links->id));
}
$news_content.= theme('pager', NULL,$limit, $record_count);

return $news_content;

not sure where is the problem but 5 records are displayed and the pagination is not displayed and i got the error
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '8' at line 1 query: 8 i

Any suggestions
Thanks

Comments

Simple pagination example

<?php
function uc_purchase()
{
$sql ="SELECT * from uc_role_exp ";
     
$role_per_page = 10;
     
// count query
 
$cq_sql ="SELECT  count(distinct oid) from uc_role_exp ";
   
$result = pager_query($sql,$role_per_page,0,$cq_sql); 
           if (
$result > 0)
        {
        while (
$role = db_fetch_object($result)) {               
        
$data .= $role->uid
        
$data .= $role_name
        
$data .= $st
             }
        }
        else {
$data .= "<p>No Any Data</p>";}
           
// print paging links
   
$data .= theme('pager', NULL, 5);
        return
$data;
        }
?>
nobody click here