I have an array of 500 arrays. I want to display this 2D array as an HTML table in such a way that only 10 rows are displayed at a time. Initially the first 10 rows are displayed. Then when the user clicks a button labelled
You use Ajax when you want/need to dynamically fetch some data from somewhere else (such as your server). Since those 500 arrays are in a MySQL table on your server, clearly you will have to fetch them at some point.
Option 1. You could use PHP to fetch all 500 arrays initially and generate the page with it (since the beginning your page will already know all rows). Upside: no need for Ajax since you already know all 500 rows since the beginning. Downside: will be slightly slower to load since you're fetching all 500 rows at once (in my opinion, unless each array is tremendously big this slowness can probably be neglected).
Option 2. Fetch the rows 10 at a time from the server using Ajax, as the user clicks the button. Upside: divides loading time in parts. Downsides: uses ajax instead of plain PHP (you could say it is slightly more complicated); also, after clicking the button the user might have to wait a while for ajax to respond - so the transition to the next 10 rows won't be instant. Since you don't want to use Ajax, go with option 1. You should be fine, there is nothing too bad about option 1, unless you are really worried about the loading time of your page.