• You are not logged in. | Login

Post a reply

January 17, 2007 10:11 am

mambojim
Member
Ranks

Paginal output+sorting, help please!

The general task is following:
There is table ‘books’ where entries about books are saved. There is page ‘library’ where the list of books is shown in e-frame.
I need to:
a) search on an attribute
b) make paginal/complete output
c) change over from paginal to complete output
d) sorting on the output within library attributes

Everything is done. But a logical error appeared (I haven’t faced anything like this before): I make paginal output with limit by request i.e. request, for example, for the third page looks like this:
SQL

SELECT * FROM `books ` WHERE...(search condition) LIMIT 8, 3

It doesn’t matter until we start dealing with sorting:

SQL

SELECT * FROM `books ` WHERE...(search condition) ORDER BY `author ` DESC LIMIT 8, 3

By such a request changing of sorting on a page also changes its contains i.e. firstly a complete request through all the base is done and then limit is extracted from it.  The question is: what should I do?


 

 

January 17, 2007 10:12 am

phppat
Member
Ranks

Re: Paginal output+sorting, help please!

You are to sort on PHP.


PHP monster

 

 

January 17, 2007 10:13 am

steven9x
Member
Ranks

Re: Paginal output+sorting, help please!

Generally first sorting is done and then limits for number of the lines extracted is set:
For example, we put out 10 entries on each page.
1st page  DESC LIMIT 0, 10
2nd page DESC LIMIT 10, 10
3rd pageDESC LIMIT 20, 10


 

 

January 17, 2007 10:14 am

mambojim
Member
Ranks

Re: Paginal output+sorting, help please!

phppat, and what if you have million of entries? I doubt it is worth doing…
steven9x, , I’d like to say the same. Can they change their places?
A thought lingered in the mind to save massive with books’ IDs in the session and extract data from bas through them if sorting is done and rewrite the massive if crossing to other page occurs.


 

 

January 17, 2007 10:15 am

monkeydude
Member
Ranks

Re: Paginal output+sorting, help please!

Is a million too much?


 

 

January 17, 2007 10:16 am

mambojim
Member
Ranks

Re: Paginal output+sorting, help please!

This means it’s impossible to do such a task by means of MySQL? Or there just was nobody to describe such ordinary things? It should be a part of every normal price/catalogue…


 

 

January 17, 2007 10:19 am

mambojim
Member
Ranks

Re: Paginal output+sorting, help please!

The problem is solved, thanks to everyone! It is solved by a sub-request:
SQL 

SELECT * FROM `lib_books` WHERE `id` IN (SELECT `id` FROM `lib_books` ORDER BY `id` LIMIT 0, 2) ORDER BY `name`;

I’ve hurried up. It isn’t solved, MySQL writes following:

This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

I’ve upgraded MySQL up to 5.0.18 – it doesn’t help. Advices still are needed.


 

 

January 17, 2007 10:19 am

phppat
Member
Ranks

Re: Paginal output+sorting, help please!

mambojim, you are to sort on PHP or cash requests on MySQL if you want to.


PHP monster

 

 
  • Actions
  • Top
ITCrimea. Ukraine Web Development Company. Professional Developers and Web Designers Team
Custom Web Designs, Internet Applications, E-Commerce Websites, Interactive Sites, Database-Driven Sites and Services