Jump to content


How to relation three tables in edit/view

relation three tables

  • Please log in to reply
5 replies to this topic

#1 Pakman_reload

Pakman_reload

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 18 October 2015 - 09:00 PM

I have three tables:

 

COUNTRIES:

id_country

---

---

---

 

CITIES:

id_city

id_country

---

---

---

 

CENTERS:

id_city

--

--

--

 

How can I show the country, the city and the center information in the edit/view screen if CENTERS is the selected table? any suggestion?



#2 osaraiva

osaraiva

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 19 October 2015 - 08:43 AM

I have three tables:

 

COUNTRIES:

id_country

---

---

---

 

CITIES:

id_city

id_country

---

---

---

 

CENTERS:

id_city

--

--

--

 

How can I show the country, the city and the center information in the edit/view screen if CENTERS is the selected table? any suggestion?

 try this:

 

public function countries()
{
try{
$crud = new grocery_CRUD();
$crud->set_table('contries');
$crud->set_subject('Conutries');
$crud->set_relation_n_n('countries', 'cities', 'countries', 'id_country','id_city','city');
 
$output = $crud->render();
 
$this->_example_output($output);
 
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}

 

I hope this helps



#3 Pakman_reload

Pakman_reload

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 19 October 2015 - 09:23 AM

Thanks for your reply, but I change the database structure for go on.



#4 Pakman_reload

Pakman_reload

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 19 October 2015 - 09:50 AM

And how can I filter the cities, in dropdown box, for show only the cities in one country at a time?



#5 osaraiva

osaraiva

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 19 October 2015 - 11:48 AM

And how can I filter the cities, in dropdown box, for show only the cities in one country at a time?

see this example

 

Country -> State -> City



#6 Pakman_reload

Pakman_reload

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 20 October 2015 - 02:00 PM

Thanks osaraiva!!







Also tagged with one or more of these keywords: relation, three, tables

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users