【发布时间】:2016-02-26 10:35:25
【问题描述】:
$header = array(
array('data' => t('S No'), 'field' => 't.id'),
array('data' => t('Country Name'), 'field' => 't.country_name'),
array('data' => t('Status'), 'field' => 't.status'),
array('data' => t('Added Date'), 'field' => 't.added_date'),
array('data' => t('Action'), 'field' => 't.id',),
array('data' => t('Action'), '',),
);
$limit = 10;
$query = db_select('countries', 't')->extend('TableSort')->extend('PagerDefault')->limit($limit)->orderby('country_name', ASC);
//condition();
$query->fields('t');
//$edit=echo '<i class="fa fa-pencil-square-o"></i>';
//$edit=echo '<i class="fa fa-pencil-square-o"></i>';
// Don't forget to tell the query object how to find the header information.
$result = $query
->orderByHeader($header)
->execute();
$rows = array();
$i=1;
foreach ($result as $row) {
$rows[] = array(
$i,
//($x === 2) ? 0 : $x+1,
//$row->id,
$row->country_name,
//$row->status,
//$row->status,
$status = ($row->status == 0) ? 'Inactive' : 'Active',
date('d-m-Y H:i:s', strtotime($row->added_date)),
l('Edit', 'mypages/countries/'. $row->id),
l('Delete', 'mypages/delete/'. $row->country_name)
);
//print_r($status);
$i++;
}
在这个数据中,我从数据库中获取数据并显示它..现在我想将状态显示为动态的,就像管理员可以根据需要修改状态..
$status = ($row->status == 0) ? 'Inactive' : 'Active',
他可以在哪里制作active or inactive
如果我们可以在下拉菜单中设置活动或非活动状态,则更好......管理员可以在哪里选择状态......之后自动更新为所选状态...... 我将 S no 显示为编号,即 .. 在第一页中工作的数字,例如编号自动递增,其中编号到第二页 .. 编号系统再次从初始值开始...
上面的解决方法是什么
【问题讨论】:
标签: php mysql arrays drupal drupal-7