monkeytooth Posted August 18, 2008 Share Posted August 18, 2008 ok, simple question I am sure. I know Ive done this before, but I cant remember how its been to long, and if I could even remember the term to call it I would look it up for a tut. But none the less I cant so here goes, cause I know you guys will help you always do.. Querying a DB.. I only want to list 50 results per page.. and have a back and next link for more then 50 results. So hit me... what do i do.. Ill even take a link if you know one to a good tutorial on the subject, save ya the time of typing here.. Link to comment https://forums.phpfreaks.com/topic/120261-get-x-to-z/ Share on other sites More sharing options...
genericnumber1 Posted August 18, 2008 Share Posted August 18, 2008 if you mean how could you paginate results see: http://www.google.com/search?q=pagination+php&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a if you mean select values where the start letters range from x-z (as per your title?) you could try something like... SELECT * FROM table WHERE value REGEXP '^([x-zX-Z])' I figure you meant the first, but just being careful. Link to comment https://forums.phpfreaks.com/topic/120261-get-x-to-z/#findComment-619547 Share on other sites More sharing options...
unkwntech Posted August 18, 2008 Share Posted August 18, 2008 SELECT col1, col2 FROM table2 WHERE id BETWEEN x AND y Link to comment https://forums.phpfreaks.com/topic/120261-get-x-to-z/#findComment-619550 Share on other sites More sharing options...
Barand Posted August 18, 2008 Share Posted August 18, 2008 I think you want a LIMIT clause ie get the first 50 rows SELECT * FROM table LIMIT 0, 50 get next 50 SELECT * FROM table LIMIT 50, 50 get Nth page of 50 SELECT * FROM table LIMIT (N-1)*50, 50 Link to comment https://forums.phpfreaks.com/topic/120261-get-x-to-z/#findComment-619560 Share on other sites More sharing options...
unkwntech Posted August 18, 2008 Share Posted August 18, 2008 Barand's suggestion is even better. Link to comment https://forums.phpfreaks.com/topic/120261-get-x-to-z/#findComment-619562 Share on other sites More sharing options...
monkeytooth Posted August 18, 2008 Author Share Posted August 18, 2008 unkwntech limit, thats what I couldnt remember I knew it was something in the select part of statement.. but forgot limit thanks Link to comment https://forums.phpfreaks.com/topic/120261-get-x-to-z/#findComment-619564 Share on other sites More sharing options...
monkeytooth Posted August 18, 2008 Author Share Posted August 18, 2008 Ok one more question, this one im not to sure about but ties into this orginal question.. 2 part question. Printing out "Displaying Records: 50-74" for example... what would I need to do? And How would I do a previous / next concept? Link to comment https://forums.phpfreaks.com/topic/120261-get-x-to-z/#findComment-619633 Share on other sites More sharing options...
Barand Posted August 18, 2008 Share Posted August 18, 2008 If you are on page 3, previous is page 2 and next is page 4. I already gave the formula for calculating the limit clause for each page, but I'll give it to you once more P = page N = rows per page ... LIMIT (P-1)*N, N Link to comment https://forums.phpfreaks.com/topic/120261-get-x-to-z/#findComment-619635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.