function listx(){
drupal_set_title("回答提问");
$output = "";
$header = array(
'标题',
);
//建立--选择表 并使用分页
$query = db_select('node', 'n')->extend('PagerDefault');
//增加查询字段
$query->addField('n', 'nid');
$query->addField('n', 'title');
//条件 status == 1 的
$query->condition('n.status', 1)->limit(1);
//ORDER BY
$query->orderBy('nid', 'DESC');
$out='';
//遍历。。。
if ($fetch = $query->execute()->fetchAll()) {
$rows = array();
foreach ($fetch as $obj) {
$rows[] = array(l($obj->title, 'node/' . $obj->nid));
}
$out.= theme('table', array('header' => $header, 'rows' => $rows));
$out.= theme('pager');
}
return $out;
}
drupal_set_title("回答提问");
$output = "";
$header = array(
'标题',
);
//建立--选择表 并使用分页
$query = db_select('node', 'n')->extend('PagerDefault');
//增加查询字段
$query->addField('n', 'nid');
$query->addField('n', 'title');
//条件 status == 1 的
$query->condition('n.status', 1)->limit(1);
//ORDER BY
$query->orderBy('nid', 'DESC');
$out='';
//遍历。。。
if ($fetch = $query->execute()->fetchAll()) {
$rows = array();
foreach ($fetch as $obj) {
$rows[] = array(l($obj->title, 'node/' . $obj->nid));
}
$out.= theme('table', array('header' => $header, 'rows' => $rows));
$out.= theme('pager');
}
return $out;
}
Drupal数据查询与展示
1947

被折叠的 条评论
为什么被折叠?



