Welcome Guest, Not a member yet? Register   Sign In
foreach in foreach
#1

Hello,
I am new and a total beginner in programming.
Also, I'm totally bad in English, which I need to translate this with Googel.

Someone has recommended this framework to me because I have an internal database for collectibles.

Before I worked with a template system and pdo grinds involved and that is my question.
So I have in my old version two grinds connected.
Now I wonder how I should do this with this version?

-----------------------

Hallo,
ich bin neu und ein totaler anfänger in sachen programmierung.
Auch bin ich in Englisch total schlecht, das ich dies mit Googel Übersetzen muss.

Jemand hat mir dieses Framework empfohlen, da ich eine Interne Datenbank für Sammelkarten habe.

Vorher hab ich nur mit einem Template System gearbeitet und pdo schleifen eingebunden und das ist nun meine frage.
Also ich habe in meiner alten version zwei schleifen miteinander verbunden.
Nun frage ich mich, wie ich das mit diesem Version machen soll?


Old Version
PHP Code:
   $land_list = array();
 
   $land__sql "SELECT
                    *
                FROM
                    db_land
                WHERE
                    db_land.tb_land_id > 1
                ORDER BY
                    db_land.tb_land_name"
;
 
   $rs $db_test->select($land__sql);
 
   $land_list['land1'] = $rs;
 
   $page->set($land_list);
 
   extract($land_list);
 
   foreach ($land1 as $list1 => $value):
 
           $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 as $list => $value):
 
           echo .....
 
           endforeach;

 
   endforeach

Framework version
Controller:
PHP Code:
           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');
 
               }

 
           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();
 
               


Model:
PHP Code:
           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', 2);
 
                   // $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();
 
               
Reply


Messages In This Thread
foreach in foreach - by Germanikus - 08-19-2017, 11:06 AM
RE: foreach in foreach - by JanFromHamburg - 08-23-2017, 02:59 AM
RE: foreach in foreach - by Germanikus - 08-24-2017, 01:32 PM
RE: foreach in foreach - by stebo - 08-24-2017, 10:08 PM
RE: foreach in foreach - by Germanikus - 08-25-2017, 03:57 AM
RE: foreach in foreach - by stebo - 08-27-2017, 10:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB