如果cate_id不同则cat_id对于数据相同,我想在同一个表中打印所有数据组创建新表并打印该类别数据 Plz帮帮我
stdClass Object
(
[id] => 5
[cat_id] => 5
[title] => Canara Bank Recruitment 2016
)
stdClass Object
(
[id] => 4
[cat_id] => 4
[title] => Canara Bank Recruitment 2016
)
stdClass Object
(
[id] => 3
[cat_id] => 3
[title] => Canara Bank Recruitment 2016
)
stdClass Object
(
[id] => 8
[cat_id] => 3
[title] => Canara Bank Recruitment 2016
)
$current_cat = 0;
foreach ($post as $key => $value)
{
if($current_cat ==0)
{
$current_cat = $value->cat_id;
echo '<div class="panel panel-default" style="width: 75%;margin: auto;">
<div class="panel-heading">'.$current_cat.'</div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Title</th>
</tr>
</thead>
<tbody>';
}
if($current_cat !=0 && $current_cat!= $value->cat_id)
{
echo '</tbody>
</table>
</div>';
}
echo '<div class="panel panel-default" style="width: 75%;margin: auto;">
<div class="panel-heading">'.$current_cat.'</div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Title</th>
</tr>
</thead>
<tbody>';
$current_cat = $value->cat_id;
echo '<tr>
<td>'.$value->title.'</td>
</tr>';
}
if($current_cat !=0)
{
echo '</tbody>
</table>
</div>';
}
我的结果有很多数据,但我这里没有提到。 Qt::Key enum
答案 0 :(得分:0)
public class PaySclip extends Activity {
HashMap<String, String> hashMap;
String name="",bank,id;
ArrayList<Login_Vo> login_VosArrayList;
SqllietDatabaseConnection sqllietDatabaseConnection;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_payslip);
login_VosArrayList=new ArrayList<Login_Vo>();
sqllietDatabaseConnection=new SqllietDatabaseConnection(PaySclip.this);
Login_Master_Vo login_Master_Vo=new Login_Master_Vo();
ArrayList<Login_Master_Vo> login = sqllietDatabaseConnection.getAll_LoginMaster();
if(login!= null && login.size() !=0) {
for(int i=0;i<=login.size();i++){
Login_Vo login_Vo=new Login_Vo();
login_Vo.setEMPLOYEE_ID(login.get(i).toString());
login_VosArrayList.add(login_Vo);
Log.v("LoginDe====>",""+login_VosArrayList);
}
}
order by cat_id
)。这将保存cat_id字段以确定您是否需要新表。更新