| | |
Pagination Without Limit in Query
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
0
#11 29 Days Ago
Take a look at the next page, it might be a solution for your problem.
http://positionabsolute.net/blog/200...pagination.php
http://positionabsolute.net/blog/200...pagination.php
0
#12 29 Days Ago
I shall put it plain and simple. While it is easily possible to loop through part of an array instead of the mysql result with pegination, an array with a trillion results will crash the server just like a reverse hash lookup table. Imagine storing a trillion results in an array and only looping through the required section - not possible unless you had a super-computer with a Petabyte of ram. Anyways, if you still are convinced you want to loop through an array then the following is an example of how.
php Syntax (Toggle Plain Text)
<?php //some array called $arr created above for ($i=$start;$i<=$end;$i++) { //regular pegination code in here. //below is an example echo "<a href=\"index.php?page=$i\">$i</a><br>"; } echo $arr[$_GET['page']];
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Sep 2009
Posts: 527
Reputation:
Solved Threads: 61
0
#15 28 Days Ago
•
•
•
•
i dont think we can use limit function directly in store procedures..!
PHP Syntax (Toggle Plain Text)
DELIMITER $$ DROP PROCEDURE IF EXISTS `dd`.`view_ratecard`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `view_ratecard`(id_tariffplan int(11),page_size int(2),row_start int(2),country_code char(30)) BEGIN if(country_code="") then select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from cc_ratecard where idtariffplan=id_tariffplan and rate_version='0' ORDER by destination asc limit row_start,page_size; else select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from cc_ratecard where idtariffplan=id_tariffplan and rate_version='0' and dialprefix like concat(country_code,'%') ORDER by destination asc limit row_start,page_size; end if ; END$$ DELIMITER ;
I hope you got this concept.
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Sep 2009
Posts: 527
Reputation:
Solved Threads: 61
0
#17 28 Days Ago
•
•
•
•
its not that simple.
for passing dynamic values in limit. i think we need prepare statement..!!
else it will throw error..!!!
u can try this
PHP Syntax (Toggle Plain Text)
DELIMITER $$ DROP PROCEDURE IF EXISTS `dd`.`view_ratecard`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `view_ratecard`(id_tariffplan int(11),page_size int(2),row_start int(2),country_code char(30)) BEGIN SET @lim = CONCAT(' LIMIT ', LimitStart_, ',', LimitCnt_); if(country_code="") then SET @q = "select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from cc_ratecard where idtariffplan=id_tariffplan and rate_version='0' ORDER by destination asc"; else SET @q = "select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from cc_ratecard where idtariffplan=id_tariffplan and rate_version='0' and dialprefix like concat(country_code,'%') ORDER by destination asc"; end if ; SET @q = CONCAT(@q, @lim); PREPARE st FROM @q; EXECUTE st; DEALLOCATE PREPARE st; END$$ DELIMITER ;
Edit: Its a bug actually, you will like to have a look at this for more information.
Last edited by network18; 28 Days Ago at 2:43 am. Reason: more information about the MySQL bug
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Jun 2009
Posts: 108
Reputation:
Solved Threads: 2
0
#18 15 Days Ago
•
•
•
•
yes, thank you so much for that and check out the below modification-
post if still there is any modification.PHP Syntax (Toggle Plain Text)
DELIMITER $$ DROP PROCEDURE IF EXISTS `dd`.`view_ratecard`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `view_ratecard`(id_tariffplan int(11),page_size int(2),row_start int(2),country_code char(30)) BEGIN SET @lim = CONCAT(' LIMIT ', LimitStart_, ',', LimitCnt_); if(country_code="") then SET @q = "select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from cc_ratecard where idtariffplan=id_tariffplan and rate_version='0' ORDER by destination asc"; else SET @q = "select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from cc_ratecard where idtariffplan=id_tariffplan and rate_version='0' and dialprefix like concat(country_code,'%') ORDER by destination asc"; end if ; SET @q = CONCAT(@q, @lim); PREPARE st FROM @q; EXECUTE st; DEALLOCATE PREPARE st; END$$ DELIMITER ;
Edit: Its a bug actually, you will like to have a look at this for more information.
Unknown column 'LimitStart_' in 'field list'
•
•
Join Date: Sep 2009
Posts: 527
Reputation:
Solved Threads: 61
0
#19 10 Days Ago
•
•
•
•
When i call the procedure.. it give this error
Unknown column 'LimitStart_' in 'field list'
PHP Syntax (Toggle Plain Text)
SET @lim = CONCAT(' LIMIT ', row_start, ',', page_size);
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
![]() |
Similar Threads
- How to use large pagination in a limited area (PHP)
- Clean Previous Next Script for MySQL results (PHP)
- pagination not displaying results (PHP)
- About LIMIT in mysql (PHP)
- search results question (PHP)
- pagination problem (PHP)
- pagination of mysql query results (PHP)
- PHP Search pagination problem (PHP)
Other Threads in the PHP Forum
- Previous Thread: how to use a external javascript file (like external CSS) in php
- Next Thread: PHP Recursion
| Thread Tools | Search this Thread |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl data database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip javascript joomla limit link links login mail match md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem protocol query radio random recursion remote script search searchbox server session sessions sms smtp soap source space sql strip_tags survey syntax system table tutorial undefined update upload url validator variable video virus votedown web website window.onbeforeunload=closeme; xml youtube






