title: PHP get next/previous record from MySQL
body: <p>I working on a website, which works like a blog. In this blog, there are articles (I add them ot another admins) and these articles have sections. I want that, when user is reading any post, that above the post, there will be 2 buttons: <code>previous article</code> and <code>next article</code>. There is MySQL database, which looks like this (<code>parent</code> is <code>id</code> of section):</p>
  
  <pre><code>+------+-------+---------+--------+
  | id   | title | content | parent | etc...
  +------+-------+---------+--------+
  | 1    | test1 | ...     | 2      |
  | 2    | test2 | ...     | 4      |
  | 3    | test3 | ...     | 2      |
  | 4    | test4 | ...     | 1      |
  | 5    | test5 | ...     | 2      |
  +------+-------+---------+--------+
  </code></pre>
  
  <p>Now, for example, user is reading <code>test3</code> and I want, that it will return me ids <code>1</code> and <code>5</code>, because <code>test1</code> is previous article with same <code>parent</code> and <code>test5</code> is next article with same <code>parent</code>.</p>
  
  <p>What should I do, to get result like this?</p>