We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

query limit and pagination

Development and Programming

Karlo Ian's avatar
Karlo Ian
59 posts
16 years ago
Karlo Ian's avatar Karlo Ian

hi..

i have notice this code in the documentation.

{exp:query limit="5" sql="SELECT title,entry_date FROM exp_weblog_titles ORDER BY entry_date DESC"}

{title} - {entry_date format="%Y %m %d"}

{paginate}
Page {current_page} of {total_pages} pages {pagination_links}
{/paginate}

{/exp:query}

but i notice that if i query the members i cannot use the limit and pagination. can i use this code?

{exp:query limit="1" pagination="bottom" sql="SELECT screen_name FROM exp_members WHERE member_id = '1' "}

cause the actual code is {exp:query sql="SELECT screen_name FROM exp_members WHERE member_id = '1' "} i cannot limit the entries. thanks..

       
Kris Khaira's avatar
Kris Khaira
38 posts
16 years ago
Kris Khaira's avatar Kris Khaira

If I’m not mistaken, pagination only works for entries and comments.

       
Karlo Ian's avatar
Karlo Ian
59 posts
16 years ago
Karlo Ian's avatar Karlo Ian

thanks for the reply.. is there any way that can be use?

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg
If I’m not mistaken, pagination only works for entries and comments.

This isn’t true– the query module has pagination:

http://expressionengine.com/docs/modules/query/index.html#pagination

       
Kris Khaira's avatar
Kris Khaira
38 posts
16 years ago
Kris Khaira's avatar Kris Khaira

Doesn’t that work only when you’re querying weblogs or comments?

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg

No, as far as I know (and believe I have used it for this) it will paginate any multiple-row query you make. It just works like weblog and comment pagination.

       
Karlo Ian's avatar
Karlo Ian
59 posts
16 years ago
Karlo Ian's avatar Karlo Ian

got the right code…

{exp:query sql="SELECT * FROM exp_members ORDER BY member_id DESC LIMIT 1"}
{screen_name}
{/exp:query}

but the problem i don’t know how to paginate this entry cause pagination tag wont work.

       
Karlo Ian's avatar
Karlo Ian
59 posts
16 years ago
Karlo Ian's avatar Karlo Ian

here’s my code

{exp:query sql="SELECT * FROM exp_members ORDER BY member_id DESC LIMIT 1"}
 {if photo_filename != ''}
        /cnchs/images/member_photos/{photo_filename} 
        {if:else}
        /cnchs/images/member_photos/no_pic.gif 
        {/if}
<a href="http://localhost/cnchs/index.php/member/{member_id}">{screen_name}</a>

{paginate}

Page {current_page} of {total_pages} pages {pagination_links}

{if previous_page}
<a href="http://{auto_path}">Previous Page</a>  
{/if}

{if next_page}
<a href="http://{auto_path}">Next Page</a>
{/if}

{/paginate}

{/exp:query}

this is the pagination the only works

{paginate}Page {current_page} of {total_pages} pages {pagination_links}
{/paginate}

there is no link to go to the other entries. unlike in the weblog and comment that pagination perfectly works.

       
Kris Khaira's avatar
Kris Khaira
38 posts
16 years ago
Kris Khaira's avatar Kris Khaira

slapshotw is right! My mistake. Pagination works with the query tag for members as well. Here’s something I just came up with.

{exp:query limit="3" paginate="both" sql="SELECT * FROM exp_members ORDER BY member_id DESC"}
  {screen_name}<br>
  {paginate}
    Page {current_page} of {total_pages} pages {pagination_links}
  {/paginate}
{/exp:query}

View the demo here.

👍 1
       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg

Karlo Ian– have you tried putting the paginate parameter in your query, like Kris has done?

       
Karlo Ian's avatar
Karlo Ian
59 posts
16 years ago
Karlo Ian's avatar Karlo Ian

yah. same here.. my mistake in the codes.. anyway thanks guys..

       
Kris Khaira's avatar
Kris Khaira
38 posts
16 years ago
Kris Khaira's avatar Kris Khaira

No problem. Anytime 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.