I produced a brand new table within the database of wordpress. Also I produce a new template page to see the records within the new table, but I wish to produce a system paging with this data ..
this really is my code
global $wpdb; $querystr = "SELECT * FROM wp_hotel WHERE id_city = ".$_GET['city-id']; $pageposts = $wpdb->get_results($querystr); if ($pageposts): ?> <div class="list_hotels"> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <div class="hotel"> <?php echo 'Hotel Name:'.$post->name-hotel; ?><br /> </div> <?php endforeach; ?> </div> <?php else : ?> <p><?php _e('No Hotel in this city ..'); ?></p> <?php endif; ?>
I would suggest applying paging with the mysql query with the addition of LIMIT towards the finish. LIMIT takes two integers, the very first which refers back to the offset (that's the number of records to skip) and also the second to the number of records to show. So for instance your query could be:
$pageoffset = $_GET['page'] * 10; $querystr = "SELECT * FROM wp_hotel WHERE id_city = ".$_GET['city-id'] . " LIMIT ". $pageoffset .", 10";
After that time the page links at the end from the page you go through what page you need to visit with the url. You might gray the current page link by checking whether it matches the page occur the url.