rajesh
Založený: 13.03.2009
Príspevky: 8
Zaslal: 2009-03-13 14:22
Návrat hore
Odpovedať s citátom
|
I want to use one input as Dropdown select box which should display data from another table
I am confused on documentation JOIN etc so please
give simple code how to achieve this
My work is stuck up there so please post your reply
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2009-03-14 17:15
Návrat hore
Odpovedať s citátom
|
Below is an un-tested example.
| Kód: |
$opts['fdd']['field_name'] = array(
'default' => '',
'maxlen' => 20,
'name' => 'Field Name',
'options' => 'ACPVDFL',
'select' => 'D', // drop down
'size|ACP' => 20,
'sort' => true,
'values' => array(
'db' => 'dbname',
'table' => 'tblname',
'column' => 'col_name',
'description'=> array(
'columns' => array('0' => 'name', '1' => 'father_name', '2' => 'mother_name'),
'divs' => array('0' => ' - ', '1' => ' - '),
),
'filters' => 'col_name = "criteria"',
'orderby' => 'yet_another_col')
); |
|
rajesh
Založený: 13.03.2009
Príspevky: 8
Zaslal: 2009-03-15 07:54
Návrat hore
Odpovedať s citátom
|
I will try ASAP and post result
|
rajesh
Založený: 13.03.2009
Príspevky: 8
Zaslal: 2009-03-15 14:26
Návrat hore
Odpovedať s citátom
|
it gives following error :
SELECT `PMEtable0`.`name` AS `qf0`,`PMEtable0`.`id` AS `qf1`,CONCAT(IFNULL(CAST(`PMEjoin2`.`name` AS CHAR),"")," - ",IFNULL(CAST(`PMEjoin2`.`name` AS CHAR),"")," - ",IFNULL(CAST(`PMEjoin2`.`name` AS CHAR),"")) AS `qf2`,`PMEtable0`.`field_name` AS `qf2_idx`,`PMEtable0`.`sku` AS `qf3`,`PMEtable0`.`mfg_sku` AS `qf4`,`PMEtable0`.`make_id` AS `qf5`,`PMEtable0`.`category` AS `qf6`,`PMEtable0`.`class` AS `qf7`,`PMEtable0`.`status` AS `qf8`,`PMEtable0`.`brand` AS `qf9`,`PMEtable0`.`price` AS `qf10`,`PMEtable0`.`msrp` AS `qf11`,`PMEtable0`.`cost` AS `qf12`,`PMEtable0`.`description` AS `qf13`,`PMEtable0`.`short_description` AS `qf14`,`PMEtable0`.`weight` AS `qf15`,`PMEtable0`.`material` AS `qf16`,`PMEtable0`.`finish` AS `qf17`,`PMEtable0`.`color` AS `qf18`,`PMEtable0`.`size` AS `qf19`,`PMEtable0`.`tax_class` AS `qf20`,`PMEtable0`.`notes` AS `qf21` FROM `products` AS `PMEtable0` LEFT OUTER JOIN `vyaparic_jeff`.`groups` AS `PMEjoin2` ON (`PMEjoin2`.`name` = `PMEtable0`.`field_name`) ORDER BY `PMEtable0`.`id` LIMIT 0, 157.234 miliseconds
|
rajesh
Založený: 13.03.2009
Príspevky: 8
Zaslal: 2009-03-15 14:41
Návrat hore
Odpovedať s citátom
|
It says before displaying query :
MySQL error 1054
Unknown column 'PMEtable0.field_name' in 'field list'
Field I added :
| Kód: |
$opts['fdd']['field_name'] = array(
'default' => '',
'maxlen' => 40,
'name' => 'group',
'options' => 'ACPVDFL',
'select' => 'D', // drop down
'size|ACP' => 20,
'sort' => true,
'values' => array(
'db' => 'vyap_jeff',
'table' => 'groups',
'column' => 'name'
)
); |
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2009-03-15 16:52
Návrat hore
Odpovedať s citátom
|
your implementation of the example is problematic. it would be more helpful if you posted the code from your original form.
replace field_name with the name of your field.
'column' needs to be an array ... 'columns' which appearing in the example.
there may be other issues with your implementation of the posted example, but these are the first two that i noticed.
|
rajesh
Založený: 13.03.2009
Príspevky: 8
Zaslal: 2009-03-15 17:15
Návrat hore
Odpovedať s citátom
|
Ok I am correcting the 'field_name' thing
For columns, If I want to populate the same with only one field from another file, how to define an array for it ?
That one goes above head a bit
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2009-03-15 19:10
Návrat hore
Odpovedať s citátom
|
Perhaps post-initializing the other values is easier to read and/or implement:
| Kód: |
$opts['fdd']['col_name']['values']['db'] = 'databaseName';
$opts['fdd']['col_name']['values']['table'] = 'extractTable';
$opts['fdd']['col_name']['values']['column'] = 'extractColumn';
$opts['fdd']['col_name']['values']['description']['divs']['-1'] = ', ';
$opts['fdd']['col_name']['values']['description']['columns']['0'] = 'desc_column_0';
$opts['fdd']['col_name']['values']['description']['divs']['0'] = ', ';
$opts['fdd']['col_name']['values']['description']['columns']['1'] = 'desc_column_1';
$opts['fdd']['col_name']['values']['filters'] = 'id = "something" ';
$opts['fdd']['col_name']['values']['orderby'] = 'another_column'; |
More examples:
| Kód: |
$opts['fdd']['creditor'] = array(
'default' => '',
'input' => '',
'maxlen' => 6,
'name' => 'Creditor',
'options' => 'ACPVDFL',
'required' => true,
'select' => 'D',
'size|ACP' => 6,
'sqlw' => 'TRIM("$val_as")',
'sort' => true,
'values' => array(
'table' => 'contacts',
'column' => 'contact_id',
'description'=> array(
'columns' => array('0' => 'company'),
),
'filters' => 'category = "Creditor" AND category <> ""',
'orderby' => 'company'
)
); |
| Kód: |
$opts['fdd']['registrar'] = array(
'default' => '',
'input' => '',
'maxlen' => 30,
'name' => 'Registrar',
'tab|C' => 'Registrar',
'options' => 'ACPVD',
'required' => false,
'select' => '',
'size|ACP' => 30,
'sqlw' => 'TRIM("$val_as")',
'sort' => true,
'values' => array(
'table' => 'registrars',
'column' => 'registrar_id',
'description' => array(
'columns' => array('registrar_name')
)
)
); |
| Kód: |
$opts['fdd']['help_category_id'] = array(
'default' => '',
'input' => '',
'maxlen|ACP' => 5,
'name' => 'Help Category Id',
'options' => 'ACPVDFL',
'select' => 'D',
'size|ACP' => 5,
'sqlw' => 'TRIM("$val_as")',
'sort' => true,
'values' => array(
'table' => 'help_category',
'column' => 'help_category_id',
'description' => array(
'columns' => array('0' => 'name')
)
)
); |
| Kód: |
// complex join example
$join_table = 'contacts'; // alias of the values table
$main_table = 'domain'; // alias of the main table
// Join table and main table remain unchanged from the above usage
// Different main column, join column and join description are used for 'owner_id' below
$join_column = 'display_name';
$join_description = 'display_name';
$main_column = 'owner_id';
$opts['fdd']['owner_id'] = array(
'default' => '0',
'input' => '',
'maxlen' => 5,
'name' => 'Owner Id',
'options' => 'ACPVD',
'required' => false,
'select' => '',
'size|ACP' => 5,
'sqlw' => 'TRIM("$val_as")',
'sort' => true,
'values' => array(
'join' => '$main_table.$main_column = $join_table.$join_column',
'table' => 'contacts',
'column' => 'contact_id',
'description' => array(
'columns' => array($join_description)
),
'filters' => 'display_name > ""'
)
); |
|
rajesh
Založený: 13.03.2009
Príspevky: 8
Zaslal: 2009-03-15 19:49
Návrat hore
Odpovedať s citátom
|
Thanks for all your help.
this is the final field define code that worked for me:
| Kód: |
$opts['fdd']['group'] = array(
'default' => '',
'maxlen' => 40,
'name' => 'group',
'options' => 'ACPVDFL',
'select' => 'D', // drop down
'size|ACP' => 20,
'sort' => true,
'values' => array(
'db' => 'vyaparic_jeff',
'table' => 'groups',
'column' => 'name' ,
'description'=> array(
'columns' => array('0' => 'id', '1' => 'id', '2' => 'name'),
'divs' => array('0' => ' - ', '1' => ' - '),
) ,
// 'filters' => 'col_name = "criteria"',
'orderby' => 'id'
)
);
|
|
rajesh
Založený: 13.03.2009
Príspevky: 8
Zaslal: 2009-04-22 07:38
Návrat hore
Odpovedať s citátom
|
When I try to make dropdown from the same table instead of another table, it generates only 2 options only whreas table have 10 rows
I am trying to make dropdown for 'name' field for 'group' field in the same table
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2009-04-22 14:52
Návrat hore
Odpovedať s citátom
|
When field names exist in the "MySQL reserved words" list, problems arise. name and group will cause problems, search mysql.com for "reserved words".
|
miles
Založený: 12.11.2009
Príspevky: 1
Zaslal: 2009-11-12 14:57
Návrat hore
Odpovedať s citátom
|
I just can't get this working so any help most appreciated.
I have two tables: products (id, productname categoryid) and categories (id, categoryname).
I want a dropdown that will list
categories dynamically from the table. I want this dropdown to reference the products.categoryid field.
Can anyone help?
Thanks
Miles
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2009-11-13 16:37
Návrat hore
Odpovedať s citátom
|
With the exception of the first 2 code snippets above, the other examples are working examples.
Documentation is here:
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.input-restrictions.html#AEN958
Since you did not post your code, it's impossible to tell what what problem you're having. (yes it can be confusing to figure out the lookups)
|
|
Odoslať novú tému
Odpovedať na tému
|
|