dragon2309 Posted March 12, 2008 Share Posted March 12, 2008 Hi all, wonder if you can help me. To cut a long story short, I am attempting to paginate my mysql results by using the "limit" clause in an SQL query, but i want the number of results per page to be able to be set by the user. The way I want to go about this may mean that at times the user hasnt selected anything, so I need a way to be able to embed a default value in a PHP $_GET function if there has been no user input, and of course for this value to be ignored if the user has expressed they want it to be different than the default (say 10 records per page) Any ideas, I'm fairly open to changing my tactics, as long as it makes sense in my head I can usually work at it, so bring your ideas. Cheers in advance, Dave Link to comment https://forums.phpfreaks.com/topic/95859-defaultrollback-values-in-php-_get-instances/ Share on other sites More sharing options...
rhodesa Posted March 12, 2008 Share Posted March 12, 2008 Just before you start pulling your data, do a test: <?php $limit = 10; if(is_numeric($_GET['limit']) && $_GET['limit'] > 0){ $limit = $_GET['limit']; } //Now pull your records using the value of $limit ?> Link to comment https://forums.phpfreaks.com/topic/95859-defaultrollback-values-in-php-_get-instances/#findComment-490773 Share on other sites More sharing options...
dragon2309 Posted March 12, 2008 Author Share Posted March 12, 2008 sweet, nice and simple, thankyou rhodesa, saved a lot of time there. regards, dave Link to comment https://forums.phpfreaks.com/topic/95859-defaultrollback-values-in-php-_get-instances/#findComment-490776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.