我试图根据是否有要打印的信息来限制打印出哪些字母。IE 如果没有“Y”条目,那么列表中不应该有“Y”。下面是我拥有的可以正常进行过滤的代码。它向服务器提交一个调用,该服务器只响应以提交的信件开头的条目。
// contextual filter list
$filters['contextual'] = array(
'#attributes' => array(
'class' => array('contextual_filter_list'),
),
'#type' => 'container',
);
$alphabets = range('A', 'Z',);
foreach ($alphabets as $value) {
$filters['contextual'][$value] = array(
'#attributes' => array(
'class' => array('contextual_letter'),
),
'#type' => 'submit',
'#value' => $value,
'#title' => t($value),
'#submit' => $value,
'#name' => 'Select',
);
}
// GET company list for A-Z filter bar
$value = $_GET["Select"];
$qry = db_select('cloud_computing_capability_data', 'cd');
$qry -> fields('cd', cloud_computing_data_company::db_fields());
// condition to query all or a single letter for companies
if ($value != 'View All'){
$qry -> condition('company',$value.'%','LIKE');
};
它打印出这个:
A | B | C | D | E | F | G |......
我需要它打印出来
A | B | C | F | G |......
如果没有“D”和“E”的条目