Well, let's say you know what image you are currently on. It's in the variable $imgnum_in. Okay?
$sel_st = "SELECT * FROM table WHERE imagenumber > $imgnum_in";
$sel_rs = mysql_query($sel_st);
$sel_ar = mysql_fetch_array($sel_st); // since we just want the image directly above, we don't place this in any kind of loop.
Now, $sel_ar[imagenumber] will contain the image number. Assuming you have set up your table correctly, that is.
-Ben