# Pagination on elasticsearch results

**URL:** <https://discuss.elastic.co/t/pagination-on-elasticsearch-results/99564>\
**Category:** Elasticsearch\
**Created:** [September 6, 2017, 11:02am UTC](https://discuss.elastic.co/t/pagination-on-elasticsearch-results/99564 "2017-09-06T11:02:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akhil\_Prashar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akhil_prashar/32/20313_2.png) [@Akhil\_Prashar](https://discuss.elastic.co/u/Akhil_Prashar)\
**Post date:** [September 6, 2017, 11:02am UTC](https://discuss.elastic.co/t/pagination-on-elasticsearch-results/99564/1 "2017-09-06T11:02:01Z")

</div>

I would like to display 20 results per page. And am thinking that total number of hits should be divided by 20 and on click of next button I should get the next 20 results.  
this is a snippet of my code  
if(isset($results['hits']))  
{  
$hits = $results['hits'];  
$rows = $hits['hits'];  
$result\_page="";  
foreach($rows as $row)

can anyone help me with addition in code I have already described from=0 and size=20 above.

I ahve added following div at the end of my php code

«

1  
2  
3  
4  
5  
»

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 4, 2017, 11:02am UTC](https://discuss.elastic.co/t/pagination-on-elasticsearch-results/99564/2 "2017-10-04T11:02:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
