Reputation: 69
Records in database:
1
5
6
7
8
10
$select_query = "SELECT * FROM images_tbl where images_id = $NextID ORDER BY images_id DESC LIMIT 1";
so if $NextID is 10 the next lowest record should be 8 not 1
Upvotes: 0
Views: 52
Reputation: 1468
$select_query = "SELECT * FROM images_tbl ORDER BY images_id ASC LIMIT 1,1";
Upvotes: 1
Reputation: 1462
you don't want the one = to $nextID, you want the next one "down".
$select_query = "SELECT Top 1 * FROM images_tbl where images_id < $NextID ORDER BY images_id DESC
Upvotes: 1