php - Codeigniter foreach and Tab trouble -
i use codeigniter not long , knowledge in things php , mysql not good. have 2 problems , hope can me there. on 1 hand, how make open tabs. shows me first id , wants see tab other content. next problem. how display content selected tab?
in old version have determined where.
view:
<div class="panel panel-info"> <div class="panel-heading "><h3 class="panel-title">porto hinzufügen</h3></div> <div class="navi-panael"> <ul class="nav nav-pills "> <?php foreach ($lands $land): ?> <li class="active"><a href="admin/porto/<?php echo $land['tb_land_id']; ?>" data-toggle="tab"><?php echo $land['tb_land_name']; ?></a></li> <?php endforeach; ?> </ul> </div> <div class="tab-content clearfix"> <?php// foreach ($lands $land): ?> <div class="tab-pane active" id="land<?php// echo $land['tb_land_id']; ?>"> <h3><?php echo $land['tb_land_name']; ?></h3> <table class="table table-hover"> <thead> <tr> <th>briefmarke</th> <th>aktionen</th> </tr> </thead> <tbody> <tr> <td> <?php// echo form_open('admin/insert_porto'); ?> <input type="hidden" name="add_porto_land" value="<?php// echo $land['tb_land_id'];?>"> <select class="form-control" name="add_porto_briefmarke"> <option value="">-</option> <?php// foreach ($briefmarkes $briefmarke): ?> <option value="<?php// echo $briefmarke['tb_briefmarke_id']; ?>"><?php// echo number_format($briefmarke['tb_briefmarke_sum'],2,",","."); ?> eur - <?php// echo $briefmarke['tb_versand_typ_name']; ?></option> <?php// endforeach; ?> </select> </td> <td><button type="submit" name="add_porto" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="senden"><span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span> eintragen</button></td> </tr> </tbody> </table> </form> <table class="table table-striped table-hover"> <thead> <tr> <th>land</th> <th>versandart</th> <th>einkaufspreis</th> <th>verkaufspreis</th> </tr> </thead> <?php foreach ($portos $porto): ?> <tbody> <tr> <td><?php// echo $porto['tb_land_name']; ?></td> <td><?php// echo $porto['tb_versand_typ_name']; ?></td> <td><?php// echo number_format($porto['tb_briefmarke_preis'],2,",","."); ?> eur</td> <td><?php// echo number_format($porto['tb_briefmarke_sum'],2,",","."); ?> eur</td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php// endforeach; ?> </div> </div>
controller:
public function porto() { if (!$this->session->userdata('logged_in')) { redirect('users/login'); } $data['portos'] = $this->admin_model->portos(); $data['lands'] = $this->admin_model->lands(); $data['briefmarkes'] = $this->admin_model->briefmarkes(); $this->load->view('templates/header_acp'); $this->load->view('admin/porto', $data); $this->load->view('templates/footer'); }
model:
public function lands() { $this->db->select('*'); $this->db->from('db_land'); $this->db->order_by('tb_land_name'); $query = $this->db->get(); return $query->result_array(); } public function briefmarkes() { $this->db->select('*'); $this->db->from('db_briefmarke'); $this->db->join('db_versand_typ', 'db_versand_typ.tb_versand_typ_id = db_briefmarke.tb_briefmarke_versand_typ'); // $this->db->where('tb_briefmarke_aktiv', 1); $this->db->order_by('tb_briefmarke_aktiv', 'desc'); $this->db->order_by('tb_briefmarke_preis', 'asc'); $query = $this->db->get(); return $query->result_array(); } public function portos() { $this->db->select('*'); $this->db->from('db_porto'); $this->db->join('db_land', 'db_land.tb_land_id = db_porto.tb_porto_land'); $this->db->join('db_briefmarke', 'db_briefmarke.tb_briefmarke_id = db_porto.tb_porto_briefmarke'); $this->db->join('db_versand_typ', 'db_versand_typ.tb_versand_typ_id = db_briefmarke.tb_briefmarke_versand_typ'); // $this->db->where('db_porto.tb_porto_land', $data); // $this->db->where('db_porto.tb_porto_land'); // $this->db->where(array('tb_porto_land' => $land['tb_land_id'])); // $this->db->where($this->admin_model->lands()); // $this->db->order_by('tb_briefmarke_aktiv', 'desc'); // $this->db->order_by('tb_briefmarke_preis', 'asc'); $query = $this->db->get(); return $query->result_array(); }
old version
<div class="panel panel-info"> <div class="panel-heading "> <h3 class="panel-title">porto hinzufügen</h3> </div> <div class="navi-panael"> <ul class="nav nav-pills "> <?php $land_list = array(); $land__sql = "select * from db_land where db_land.tb_land_id = 1 order db_land.tb_land_name"; $rs = $db_test->select($land__sql); $land_list['land'] = $rs; $page->set($land_list); extract($land_list); foreach ($land $list => $value): ?> <li class="active"><a href="#land<?php echo $land[$list]['tb_land_id']; ?>" data-toggle="tab"><?php echo $land[$list]['tb_land_name']; ?></a></li> <?php endforeach; $land_list = array(); $land__sql = "select * from db_land where db_land.tb_land_id > 1 order db_land.tb_land_name"; $rs = $db_test->select($land__sql); $land_list['land1'] = $rs; $page->set($land_list); extract($land_list); foreach ($land1 $list1 => $value): ?> <li><a href="#land<?php echo $land1[$list1]['tb_land_id']; ?>" data-toggle="tab"><?php echo $land1[$list1]['tb_land_name']; ?></a></li> <?php endforeach; ?> </ul> </div> <div class="tab-content clearfix"> <?php $land_list = array(); $land__sql = "select * from db_land where db_land.tb_land_id = 1 order db_land.tb_land_name"; $rs = $db_test->select($land__sql); $land_list['land'] = $rs; $page->set($land_list); extract($land_list); foreach ($land $list => $value): ?> <div class="tab-pane active" id="land<?php echo $land[$list]['tb_land_id']; ?>"> <h3><?php echo $land[$list]['tb_land_name']; ?></h3> <form method="post" action="index.php?page=option&step=porto"> <input type="hidden" name="add_porto_land" value="<?php echo $land[$list]['tb_land_id'];?>"> <table class="table table-hover"> <thead> <tr> <th>briefmarke</th> <th>aktionen</th> </tr> </thead> <tbody> <tr> <td> <select class="form-control" name="add_porto_briefmarke"> <option value="">-</option> <?php $briefmarke_list = array(); $briefmarke__sql = "select * from db_briefmarke left join db_versand_typ on db_versand_typ.tb_versand_typ_id = db_briefmarke.tb_briefmarke_versand_typ order db_briefmarke.tb_briefmarke_aktiv desc, db_briefmarke.tb_briefmarke_preis"; $rs = $db_test->select($briefmarke__sql); $briefmarke_list['briefmarke'] = $rs; $page->set($briefmarke_list); extract($briefmarke_list); foreach ($briefmarke $list => $value): ?> <option value="<?php echo $briefmarke[$list]['tb_briefmarke_id']; ?>"><?php echo number_format($briefmarke[$list]['tb_briefmarke_sum'],2,",","."); ?> eur - <?php echo $briefmarke[$list]['tb_versand_typ_name']; ?></option> <?php endforeach; ?> </select> </td> <td><button type="submit" name="add_porto" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="senden"><span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span> eintragen</button></td> </tr> </tbody> </table> </form> <table class="table table-striped table-hover"> <thead> <tr> <th>land</th> <th>versandart</th> <th>einkaufspreis</th> <th>verkaufspreis</th> </tr> </thead> <?php $porto_list = array(); $porto__sql = "select * from db_porto left join db_land on db_land.tb_land_id = db_porto.tb_porto_land left join db_briefmarke on db_briefmarke.tb_briefmarke_id = db_porto.tb_porto_briefmarke left join db_versand_typ on db_briefmarke.tb_briefmarke_versand_typ = db_versand_typ.tb_versand_typ_id where db_porto.tb_porto_land = 1"; $rs = $db_test->select($porto__sql); $porto_list['porto'] = $rs; $page->set($porto_list); extract($porto_list); foreach ($porto $list => $value): ?> <tbody> <tr> <td><?php echo $porto[$list]['tb_land_name']; ?></td> <td><?php echo $porto[$list]['tb_versand_typ_name']; ?></td> <td><?php echo number_format($porto[$list]['tb_briefmarke_preis'],2,",","."); ?> eur</td> <td><?php echo number_format($porto[$list]['tb_briefmarke_sum'],2,",","."); ?> eur</td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endforeach; $land_list = array(); $land__sql = "select * from db_land where db_land.tb_land_id > 1 order db_land.tb_land_name"; $rs = $db_test->select($land__sql); $land_list['land1'] = $rs; $page->set($land_list); extract($land_list); foreach ($land1 $list1 => $value): ?> <div class="tab-pane" id="land<?php echo $land1[$list1]['tb_land_id']; ?>"> <h3><?php echo $land1[$list1]['tb_land_name']; ?></h3> <form method="post" action="index.php?page=option&step=porto"> <input type="hidden" name="add_porto_land" value="<?php echo $land1[$list1]['tb_land_id'];?>"> <table class="table table-hover"> <thead> <tr> <th>briefmarke</th> <th>aktionen</th> </tr> </thead> <tbody> <tr> <td> <select class="form-control" name="add_porto_briefmarke"> <option value="">-</option> <?php $briefmarke_list = array(); $briefmarke__sql = "select * from db_briefmarke left join db_versand_typ on db_versand_typ.tb_versand_typ_id = db_briefmarke.tb_briefmarke_versand_typ order db_briefmarke.tb_briefmarke_aktiv desc, db_briefmarke.tb_briefmarke_preis"; $rs = $db_test->select($briefmarke__sql); $briefmarke_list['briefmarke'] = $rs; $page->set($briefmarke_list); extract($briefmarke_list); foreach ($briefmarke $list => $value): ?> <option value="<?php echo $briefmarke[$list]['tb_briefmarke_id']; ?>"><?php echo number_format($briefmarke[$list]['tb_briefmarke_sum'],2,",","."); ?> eur - <?php echo $briefmarke[$list]['tb_versand_typ_name']; ?></option> <?php endforeach; ?> </select> </td> <td><button type="submit" name="add_porto" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="senden"><span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span> eintragen</button></td> </tr> </tbody> </table> </form> <table class="table table-striped table-hover"> <thead> <tr> <th>land</th> <th>versandart</th> <th>einkaufspreis</th> <th>verkaufspreis</th> </tr> </thead> <?php $porto_list = array(); $porto__sql = "select * from db_porto left join db_land on db_land.tb_land_id = db_porto.tb_porto_land left join db_briefmarke on db_briefmarke.tb_briefmarke_id = db_porto.tb_porto_briefmarke left join db_versand_typ on db_briefmarke.tb_briefmarke_versand_typ = db_versand_typ.tb_versand_typ_id where db_porto.tb_porto_land = ".$land1[$list1]['tb_land_id'].""; $rs = $db_test->select($porto__sql); $porto_list['porto'] = $rs; $page->set($porto_list); extract($porto_list); foreach ($porto $list => $value): ?> <tbody> <tr> <td><?php echo $porto[$list]['tb_land_name']; ?></td> <td><?php echo $porto[$list]['tb_versand_typ_name']; ?></td> <td><?php echo number_format($porto[$list]['tb_briefmarke_preis'],2,",","."); ?> eur</td> <td><?php echo number_format($porto[$list]['tb_briefmarke_sum'],2,",","."); ?> eur</td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endforeach; ?> </div> </div>
Comments
Post a Comment