⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to relation three tables in edit/view



Pakman_reload
  • profile picture
  • Member

Posted 18 October 2015 - 21: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?


osaraiva
  • profile picture
  • Member

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


Pakman_reload
  • profile picture
  • Member

Posted 19 October 2015 - 09:23 AM

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


Pakman_reload
  • profile picture
  • Member

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?


osaraiva
  • profile picture
  • Member

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


Pakman_reload
  • profile picture
  • Member

Posted 20 October 2015 - 14:00 PM

Thanks osaraiva!!