Over a million developers have joined DZone.

Getting Results For Paged Display

·
We can present these blog entries a better way: as a page of formatted results with links to more
results. We can do that using Drupal’s pager. Let’s grab all of the blog entries again, only this
time we’ll display them as a paged result, with links to additional pages of results and “first and
last” links at the bottom of the page.


$sql = "SELECT * FROM {node} n WHERE type = 'blog' AND status = 1 ORDER BY
n.created DESC"
$result = pager_query(db_rewrite_sql($sql), 0, 10);
while ($data = db_fetch_object($result)) {
$node = node_load($data->nid);
print node_view($node, TRUE);
}
// Add links to remaining pages of results.
print theme('pager', NULL, 10);
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}