Jagand Posted June 16, 2010 Share Posted June 16, 2010 I am creating a webpage and one of my requirements is to fetch records from database. If the query results in say 30 records, I should display first 10 records in current page and create dynamic links numbered 2,3 at bottom of the page. Since the logic that drives each of these pages is identical and the only variable I see is $starting_rec (which gives initial limit of the query), I just want to create single PHP + MySQL page and use some logic to get value of $starting_rec depending on the link that user has clicked. What is the best way to determine which link user clicked? Quote Link to comment https://forums.phpfreaks.com/topic/204964-creating-dynamic-page-numbers-and-related-links-in-php/ Share on other sites More sharing options...
ignace Posted June 16, 2010 Share Posted June 16, 2010 if (false != ($result = mysql_query('SELECT .. FROM table')) { if (0 < ($row_count = mysql_num_rows($result))) { $page = ctype_digit($_GET['p']) ? intval($_GET['p']) : 1; $items_per_page = 20; $number_of_pages = floor($row_count / $items_per_page); $offset = ($page - 1) * $items_per_page; for ($index = $offset; $index < $row_count && $index < $offset + $items_per_page; ++$index) { $field1 = mysql_result($result, $index, 'field1'); $field2 = mysql_result($result, $index, 'field2'); } } mysql_free_result($result); } Quote Link to comment https://forums.phpfreaks.com/topic/204964-creating-dynamic-page-numbers-and-related-links-in-php/#findComment-1073054 Share on other sites More sharing options...
Jagand Posted June 16, 2010 Author Share Posted June 16, 2010 In above code, dynamic links get created. My need is to determine which dynamic link was clicked? Quote Link to comment https://forums.phpfreaks.com/topic/204964-creating-dynamic-page-numbers-and-related-links-in-php/#findComment-1073057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.