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