By sagar.sijju on
Hi all,
i am newbee to Drupal...i am trying to display users with their email address and name and other details in a page(only 5 records per page). but i am unable to print the page links. any one plz help me.
here i am sending the code:
// ;$id$
function usersreport_perm()
{
return array('Access User Report');
}
/*
* Implemnting callback function usersreport_report
*/
function usersreport_report()
{
$sql = "select * from users where uid!='0'";
$qry = pager_query($sql,2,10);
$output = '';
while($res = db_fetch_array($qry))
{
$output .= $res['uid']."------".$res['name']."------".$res['mail']."------".$res['created']."<br>";
}
$output .= theme('pager');
return $output;
}
/**
* Implementing menu hook
**/
function usersreport_menu()
{
$items = array();
$items['usersreport'] = array(
'path' => 'usersreport',
'title' => t('Users Report'),
'description' => 'Users Report',
'page callback' => 'usersreport_report',
'access callback' => 'user_access',
'access arguments' => array('Access User Report'),
'type' => MENU_CALLBACK
);
return $items;
}
Comments
Views
I recommend you use Views module for this. It would be incredibly simple to do something like that in Views 2, which now supports queries on Users, and no coding (other than theming it to look how you prefer) will be necessary. Views supports regular paging, as well as AJAX paging.
-- David
absolutecross.com
[new guide/lesson in progress: Creating a CCK and Views powered Drupal site - feedback welcome]
can u plz explain me step by step process
can u plz explain me step by step process or any example code for pager links
Thanks
Sagar
Use <?php function
Use
Regards,
Vijay
Thanks,
Vijay Thummar
still no use
after replacing the above code also, not showing the page links
Thanks & Regards,
sagar.
Wrong : <?php $sql = "select
Wrong :
$sql = "select * from users where uid!='0'";Good :
$sql = "SELECT * FROM {users} WHERE uid!='0'";If the query is lowercase, theme('pager') won't work...
Regards