| Index
» Projekty
» phpMyEdit
» Fórum
» Display value based on another table |
 |
Kingstepper
Založený: 27.09.2010
Príspevky: 7
Zaslal: 2010-09-28 14:35
Návrat hore
Odpovedať s citátom
|
I have 2 tables:-
table tests
id
name
table results
id
test_id
value
I'm trying to us phpMyEdit with table results but wish to display (in view mode) tests.name rather than results.test_id (where results.test_id = tests.id).
I have used:-
$opts['fdd']['test_id'] = array(
'name' => 'Test',
'select' => 'T',
'maxlen' => 11,
'sort' => true,
'values' => array(
'table' => 'tests',
'column'=> 'name'
)
);
to give a drop-down in change/add mode but cannot see how to display in view mode.
Thanks
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-09-29 12:49
Návrat hore
Odpovedať s citátom
|
Try values2 instead of values.
|
Kingstepper
Založený: 27.09.2010
Príspevky: 7
Zaslal: 2010-09-29 14:02
Návrat hore
Odpovedať s citátom
|
| doug Napísal: |
| Try values2 instead of values. |
No this doesn't have any effect in View mode.
Thanks for your interest!
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-09-29 14:49
Návrat hore
Odpovedať s citátom
|
Below is a working lookup from a script which I happened to have open. Perhaps the lack of a filter is causing the problem.
| Kód: |
$opts['fdd']['domain_usage'] = array(
'default' => 'cPanel',
'help|ACP' => '<a href="'.$opts['self'].'?s=8&t=1&f=200&PME_sys_operation=PME_op_Add&tb='.$opts['tb'].'&col=domain_usage" target="_blank">Add Label</a>',
'maxlen' => 40,
'name' => 'Domain Usage',
'options' => 'ACPVDFL',
'select' => 'D',
'size' => 40,
'sqlw' => 'IF($val_qas = "", NULL, $val_qas)',
'sort' => true,
'values' => array(
'table' => 'dev_items',
'column' => 'item_text',
'filters' => 'item_table = "dev_domains" AND item_column = "domain_usage" AND deleted = "0"',
'orderby' => 'item_text'
)
); |
|
Kingstepper
Založený: 27.09.2010
Príspevky: 7
Zaslal: 2010-09-29 20:40
Návrat hore
Odpovedať s citátom
|
This didn't work either I'm afraid. The user guide suggests that 'filters' are used for filtering items in dropdown during Add/Edit so not sure that this is right to use here.
In fact things are worse than I thought - although I had such a dropdown, on saving this value is not added to the record (a zero is added in this column).
|
Kingstepper
Založený: 27.09.2010
Príspevky: 7
Zaslal: 2010-09-30 22:00
Návrat hore
Odpovedať s citátom
|
By trial and error I've found the solution.
| Kód: |
$opts['fdd']['test_id'] = array( // column 'test_id' in table 'results'
'name' => 'Assay',
'select' => 'T',
'maxlen' => 11,
'sort' => true,
'colattrs' => 'width="180px"',
'values' => array(
'table' => 'tests', // look-up table
'column' => 'id', // look-up column ('results'.'test_id' = 'tests'.'id')
'description' => 'name' // results column in table 'tests'
)
); |
does what is required. Perhaps obvious with hindsight?
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|