O
O
Optimus2015-12-29 20:08:35
PHP
Optimus, 2015-12-29 20:08:35

SQL query with indent?

In the database in one table there are articles from different sections, I display the last 10 articles
site / articles / section /
site.ru/art/raz1/

SELECT `id` FROM `articles` WHERE `raz`='1' ORDER BY `id` DESC limit 10

So everything works, but...
...a paginator appears: site/articles/section/paginator/
site.ru/art/raz1/2/
What request should I ask? In fact, I need the same data as in the previous request, only not the last 10 articles, but the penultimate one, but on page 3 of the paginator PrePrevLast 10 articles. It's like an indent or a shift is somehow called. Who will tell you how to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rikcon, 2015-12-29
Pyan @marrk2

habrahabr.ru/post/217521

A
Arman, 2015-12-29
@Arik

<?php

$skip = (max($page, 1) - 1) * 10

$sql = 'SELECT `id` FROM `articles` WHERE `raz`='1' ORDER BY `id` DESC limit '. $skip .', 10';

?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question