说个思路不知道对不对
假定当前类$cur_cls已知,图片$cur_id已知
那么
前一个
$sel_sql="select * from table where class='$cur_cls' and id<'$cur_id' limit 0,1";
后一个
$sel_sql="select * from table where class='$cur_cls' and id>'$cur_id' limit 0,1";你测试一下,不知道对不对,我等你的结果。

解决方案 »

  1.   

    前一个
    $sel_sql="select * from table where class='$cur_cls' and id<'$cur_id' order by id desc limit 0,1";
    后一个
    $sel_sql="select * from table where class='$cur_cls' and id>'$cur_id' order by id limit 0,1";
      

  2.   


    $sel_sql="select * from table where class='a' and id<'$cur_id' order by id desc limit 0,1";

    $sel_sql="select * from table where class='c' and id>'$cur_id' order by id asc limit 0,1";
      

  3.   

    給一個你b类的数据库表名做参数,
    或则你设计的数据库如下
    类别||路径       ||hit数目||
    b   ||d:\b\1.jpg ||2      ||
    a   ||d:\a\1.jpg ||3      ||
    在next和forward按纽按下的时候带上你的参数a,b或c
    然后select * from table where class=$xxx 
    去出的数据都放在一个数组里面,然后用数组下标访问!