Welcome Guest, Not a member yet? Register   Sign In
Newbie question : How to specify relationship between tables ?
#1

[eluser]Unknown[/eluser]
Hello,

Sorry to ask a so stupid question but ... :-)
I have to tables :
Country :
id
country_name

Wine :
id
wine_name
country

I want to have a drop down list when i add a new wine in my database with all the countries.

Can someone help me ?
Thanks.

Dominique.
#2

[eluser]zdknudsen[/eluser]
This is one of the things CodeIgniter does not do for you. You'll have to do this yourself using the database library. Smile
#3

[eluser]Michael Wales[/eluser]
Pretty simple (not as easy as Ruby on Rails, which virtually does it automagically), but simple nonetheless. From your controller's method, make a query to select all of the country names, dump that into an array, pass it to your view, and then either use the form_dropdown() form helper or foreach() through it using your own XHTML select tag.
#4

[eluser]Unknown[/eluser]
You are really fast to answer !
;-)

I was asking this question because i was trying just before cakephp.

Thanks for your answers. I'm going to try.

Dominique.




Theme © iAndrew 2016 - Forum software by © MyBB