I’m a beginner in mysql and I wanted to know if there is a faster way to do the following:
I have a table like this:
------------------------------
| Pages | Creation |
------------------------------
| bar | 2012-10-10 10:11:10|
| blah | 0000-00-00 00:00:00|
| foo | 2012-10-10 10:10:10|
------------------------------
There is no primary key.
I want to know the page before and the page after a specific page (Ordered by date of creation).
Currently I do:
Sql: SELECT * FROM table ORDER BY creation
Php:
foreach($r as $c=>$t)
{
if($t['pages']==$thepageiwant)
{
$before=$c-1;
$after=$c+1;
break;
}
}
Previous page:
Next page: