destoon 上一篇,下一篇

  1. 获取当前文章的$id
  2. 查询当前表的$id
  3. 用当前文章的$id与查询当前表的$id作比较,小于则为上一篇
  4. 查询语句为升序,大于则为上一篇
$last = array();
    $id = $_GET['itemid'];
    $r = $db->get_one("SELECT itemid from {$table} where linkurl like '%$id%'ORDER BY itemid desc LIMIT 1", 'CACHE');
    $itemidl =  $r['itemid'];

    $hang = $db->query("select * FROM {$table} where itemid < $itemidl ORDER BY itemid desc LIMIT 1 ");

    while($ha = $db->fetch_array($hang)) {

        $last[] = $ha;
    }

 

你可能感兴趣的:(php)