Please help me how to display by id so that when the number id grew the id-2 post was displayed so that SELECT * FROM chess WHERE id = $ id-2 was obtained

<div class="postblock"> <?php $articles = mysqli_query($link,"SELECT * FROM chess WHERE id < 5 ORDER BY id DESC LIMIT 5"); ?> <?php WHILE( $art = mysqli_fetch_assoc($articles) ){ ?> <div class="post"> <a href="http://localhost/madbet/posts"><img src="http://localhost/madbet/img/images/chess/<?php echo $art['image-1'] ?>"></a> <p><i class="fa fa-clock-o" aria-hidden="true"></i><?php echo date_create($art['pubdate'])->Format('H:i');?></p> <a href="http://localhost/madbet/posts"><h1><?php echo mb_substr($art['title'],0,33)?></h1></a> <h4 style="margin-bottom:40px;"><?php echo mb_substr($art['text-1'],0,140).'...';?></h4> </div> <?php } ?> </div> 
  • Unclear. Show an example (data and desired result) or something ... - Akina
  • id=id-2 <- this is definitely unearthly math! - Visman Sep.
  • SELECT c1.* FROM chess c1 inner join chess c2 on c1.id = c2.id - 2 - Qwertiy
  • And if the id will be equal to 2 or 1? - DaemonHK
  • Well then nothing should not deduce! But if I have the last id 15 I want to display everything except 14.15 - Razmik

1 answer 1

If you just need to ignore the first 2 entries, then

 SELECT * FROM `chess` LIMIT 10000, 2 

If you need to ignore the record by the number transferred, as well as one less, then:

 SELECT * FROM `chess` WHERE id != $id AND id != $id - 1 
  • thanks a lot - Razmik