$query = $_SGLOBAL['db']->query('SELECT i.* FROM '.tname('spaceitems').' i WHERE i.itemid>\''.$itemid.'\' AND catid = \''.$news['catid'].'\' AND type=\''.$news[type].'\' ORDER BY itemid LIMIT 0,1');
$newspre = $_SGLOBAL['db']->fetch_array($query);
$query = $_SGLOBAL['db']->query('SELECT i.* FROM '.tname('spaceitems').' i WHERE i.itemid<\''.$itemid.'\' AND catid = \''.$news['catid'].'\' AND type=\''.$news[type].'\' ORDER BY itemid DESC LIMIT 0,1');