Link to home
Start Free TrialLog in
Avatar of John Tas
John Tas

asked on

Pagination - client side vs server side

I need to paginate excerpts from all the articles that I have written which is 200+ articles. These excerpts need to be split into different pages. Do I need a database for this or should I stick with client side? Which one would be faster?

I'm talking about something like this.

https://www.techpowerup.com/reviews/
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

200 is a small number and displaying this via a traditional database like MySql or MS SQL vs static json or htnml data is not going to make much difference in just sending info to the screen.  Using static json text file as your database could potentially get you up and running faster, but if you feel there may be many edits/editions down the road, it may be worth the time to set up a database.  

Either way, a small number of records like this can be sent to the browser all at once be it via a db or static json/text data.  Then let your js/jquery manage the pagination.
Avatar of John Tas
John Tas

ASKER

Well, I'm currently storing the data in an array. I plan on adding a new element every day to this array so the array will get larger and larger over time. What would happen if this array got huge, say 20K - 50K elements? Also, what's the best way to optimize this array when the array gets huge?

$pages_articles=array(
'<div class="article-loop"><img src="http://i.imgur.com/CmU3tnl.jpg"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/TDdxS9H.png"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/39rpmwB.jpg"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/1lBZQ1B.png"></div>',
'<div class="article-loop"><img src="https://i.imgur.com/Y5Ld4Qfh.jpg"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/8HumESY.jpg"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/CqCZBvk.png"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/q3I72Ul.png"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/YrzP9A3.jpg"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/xWmaeb6.png"></div>',
'<div class="article-loop"><img src="https://i.imgur.com/GpGBVZW.png"></div>',
'<div class="article-loop"><img src="http://i.imgur.com/wQVPRVp.png"></div>');
$total_count = sizeof($pages_articles);
}
In that case, you want to store your data in a db.  Your data should only contain the image location http://i.imgur.com/CmU3tnl.jpg. Then use php to output json to the page and finally use js/jquery to process the json and feed to your html.
SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial