This topic is locked
[SOLVED]

 display multiple fileds in add page based on related data in another table

10/9/2012 1:25:45 PM
PHPRunner General questions
A
aptivus author

Hi everyone,

I'm stuck with this issue, but I guess the thing could be solved easily (if only I was a mysql guru).
I have a table for the languages with fields

[language_code, language_folder, language_name]



Then, I have a table for products categories as follows

[id,txt_cat_name,parent,status]


The field txt_cat_name is a reference to a table of text contents in different languages and it is structured as follows

[id,language,message]


Example datas for what I'm writing are:

LANGUAGES

[language_code, language_folder, language_name]

IT,italian,Italiano

EN,english,English
CATEGORIES

[id,txt_cat_name,parent,status]

1,1,NULL,1
TEXT MESSAGE TABLE

[id,language,message]

1,IT,Gelati

2,EN,Ice creams
When I write a record I use a stored function in SQL that combines all the things. I put this thing in "Before record added" action.

Everything works fine.

What I would like to do now is to have N fields in "categories_add.php" page, one for each language sored in the languages table.
Let say that I have IT, EN, FR, JP

well...I would like that PHPRunner could automatically show

one field for category name in IT (italian)

one in FR (french)

one in EN (english)

and one in JP (japanese)
Basically, I would like something like(pseudo code):

SELECT COUNT(*) as c, language_code as lc FROM languages;
FOR(i=1;i<=c)

{

SELECT writeTextFunction(txt_cat_name) as catName_'.lc.';

}



So when I am in categories_add.php page I can see 4 fields for the category name, one for each language.

I know how to do this in PHP. I'm not sure where to put the snippet?

Before display? Add page:before process?

Or can that be done via SQL only?
I hope you can help me understand how to get out of this jam.

Thanks a lot,

Francesco