Look also into this other options with may be better

http://www.mengu.net/post/pagination-with-web2py
http://packages.python.org/web2py_utils/paginate.html

On Oct 1, 6:39 pm, Andrew Evans <[email protected]> wrote:
> also there was a syntax error in that code don't know if you want to fix
> it..
>
> These two lines needed to close the A function
>
> backward=A('previous', _href=URL(r=request,args=[page-1])) if page else ''
> forward=A('next', _href=URL(r=request,args=[page+1])) if len(rows) else
> ''
>
> in the example they weren't anyway ty
>
> On Fri, Oct 1, 2010 at 4:36 PM, Andrew Evans <[email protected]> wrote:
> > Ok that pagination works better.
>
> > But for some reason the last entry in the db is always cut any ideas?
> > probably something I am doing but would appreciate some help
>
> > *cheers
>
> > here is the code
>
> > thank you for the help thus far
>
> > def index():
> >     if len(request.args):
> >        page=int(request.args[0])
> >     else:
> >        page=0
> >     query=db.product.id>0
> >     rows=db(query).select(db.product.ALL, orderby=db.product.product_name,
> > groupby=db.product.category, limitby=(page,page+1))
> >     backward=A('previous', _href=URL(r=request,args=[page-1])) if page else
> > ''
> >     forward=A('next', _href=URL(r=request,args=[page+1])) if len(rows) else
> > ''
> >     return dict(rows=rows,backward=backward,forward=forward)
>
> > Cheers
>
> > Andrew
>
> > On Fri, Oct 1, 2010 at 3:19 PM, mdipierro <[email protected]> wrote:
>
> >> Try this:
>
> >>http://www.web2py.com/AlterEgo/default/show/63
>
> >> On Oct 1, 4:41 pm, Andrew Evans <[email protected]> wrote:
> >> > Hello I am trying to create some pagination for my site I am building.
> >> > However this pagination is a bit messed up, (I forget exactly where I
> >> found
> >> > it) when I click next it doesn't display anything else in the database.
>
> >> > Also a few other things are rather odd about it.
>
> >> > Does anyone have some good solid working pagination they can share with
> >> me
>
> >> > *cheers
>
> >> > Here is the code
>
> >> > def index():
> >> >     if len(request.args):
> >> >         page=int(request.args[0])
> >> >     else:
> >> >         page=0
> >> >     items_per_page=2
> >> >     limitby=(page*items_per_page,(page+1)*items_per_page + 1)
> >> >     rows=db().select(db.product.ALL, orderby=db.product.product_name,
> >> > groupby=db.product.category, limitby=limitby)
> >> >     return dict(rows=rows,page=page,items_per_page=items_per_page)
>
> >> ----------------------------------------------------------------------------------------------------------------------------------
>
> >> > {{i = i+1}}
> >> > {{pass}}
>
> >> > <table align="center">
> >> > <tr>
>
> >> > {{if page:}}
> >> > <td align="center">
>
> >> > <a href="{{=URL(r=request, args=[page-1])}}">previous</a>
>
> >> > {{pass}}
> >> > </td>
>
> >> > {{if len(rows)>=items_per_page:}}
> >> > <td align="center">
>
> >> > <a href="{{=URL(r=request, args=[page+1])}}">next</a>
> >> > {{pass}}
>
> >> > </td>
> >> > </tr>
> >> > </table>
>
>

Reply via email to