I have a problem with displaying data from mysql database. My client requires to display paginated data - i.e.15 rows per page, there sholdn't be any scrollers, and at the same time, data displayed are ordered by category and for each new category I have to add 2 new rows at the table displayed in php file, sth. like:
r1-Category1
r2-item name | item data1 ...
db-item1
db-item2
...new item x
r1-Category2
r2-item name | item data1 ...
db-item 1
db-item 2
...
I tried to call all the data from database, for each category added 2 new rows (such as name of the category and th for the items displayed), put them in an array, then counting all the rows and divided to get pages with 15 results on it, and continue processing with javascript. The cons of this method is, that here is a lot of data and it takes almost a minute to get the job done.
The best solution - to get the data displayed ASAP IMO is to use pagination, but I need to define a limit .. and there is a problem - how can I define a limit if the categories among 15 results can be various (sometimes 3, 4 or just one) ? Thus I tried to find out how many categories are within 15 results from database, then make another call to database with a limit = limit-2x(no of categories) ... for the first page works fine, but for the next pages not, obvious ... for example: in the limit of 15 rows are for example 3 categorires , so I need to change limit to 9 ... if I change limit to 9row, there are only 2 categories ... very complicated, but the point is, that this cannot work from my point of view.
Do you have an idea how to solve this?
the first solution is unacceptable for my customer, and the second impossible from my point of view .. but his opinion is that in programming everything is possible ..