Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Utorok, 24. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Concat 3 fields

phpMyEdit Configuration     Concat 3 fields
Odoslať novú tému   Odpovedať na tému    
 
Topshed9     Založený: 14.01.2008   Príspevky: 34  
Príspevok Zaslal: 2009-08-05 15:47
Návrat hore  Odpovedať s citátom     

Hi some assistance needed please,
I am trying to align 3 fields so they appear as 1 field
The 3 fields are
Citácia:
Field 1 pre_ln (int1)
Field 3 main_ln (int5)
Field 3 suf_ln (char1)

I need to display them as one field
I can make it work using lines 1 or 2 but not line 3
Kód:
1 'sql|LFV'  =>"concat(pre_ln,' ',mainr_ln)"
2 'sql|LFV'  =>"concat(main_ln,' ',suf_ln)"
3 'sql|LFV'  =>"concat(pre_ln,' ',main_ln,' ',suf_ln)"

The reason for Field 1 is that it contains a leading zero that gets removed if included in Field 2 and only occurs in less tha 1 % of the records

Please help someone
Thankyou Roy..

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-08-06 12:55
Návrat hore  Odpovedať s citátom     

The value may need to be in single quotes, and the spaces enclosed with double quotes.

Kód:
'sql|LFV' => 'concat(pre_ln, " ", main_ln, " ", suf_ln)'


 
Topshed9     Založený: 14.01.2008   Príspevky: 34  
Príspevok Zaslal: 2009-08-08 06:58
Návrat hore  Odpovedať s citátom     

Hi Doug,

I am afraid that did not solve my problem it came up with an error message
Citácia:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in D:\hshome\topshed\britishsteam.com\PHP\-ln_User.php on line 88

Kód:
$opts['fdd']['other_no'] = array(
  'name'     => 'LNER
  no.',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
  'sql|LFV' => 'concat(lne_pre, " ", other_no, " ", suf_ln)';

I have tried starting the concat at the first field
Kód:

$opts['fdd']['lne_pre'] = array(
  'name'     => 'LNER',
  'select'   => 'T',
  'maxlen'   => 1,
  'sort'     => true
  'sql|LFV' => 'concat(lne_pre, " ", main_ln, " ", suf_ln)'
);


Any other idea's most welcome
Thanks Roy...

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-08-08 08:33
Návrat hore  Odpovedať s citátom     

Below is a working example tested in one of my forms.

Kód:
$opts['fdd']['nickname'] = array(
  'default'    => '',
  'help|ACP'   => 'Business Name',
  'maxlen'     => 60,
  'name'       => 'Business Name',
  'options'    => 'ACPVDFL',
  'select'     => 'T',
  'size'       => 60,
  'sqlw'       => 'TRIM("$val_as")',
  'sort'       => true
);

$opts['fdd']['nickname']['sql|LFV'] = 'concat(nickname, " ", primary_domain_name, " ", billing_address_1)';


 
Topshed9     Založený: 14.01.2008   Príspevky: 34  
Príspevok Zaslal: 2009-08-08 17:33
Návrat hore  Odpovedať s citátom     

Thank you for the code...
I must be slow here, I have played with your solution but I cannot get it to work as I expect
The original Code for the 3 fields is
Kód:
$opts['fdd']['lne_pre'] = array(
  'name'     => 'Prefix',
  'select'   => 'T',
  'maxlen'   => 1,
  'sort'     => true
);
$opts['fdd']['other_no'] = array(
  'name'     => 'LNER No',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['lner_suf'] = array(
  'name'     => 'Suffix',
  'select'   => 'T',
  'maxlen'   => 1,
  'sort'     => true
);

Using your example I came up with
Kód:
$opts['fdd']['lne_pre'] = array(
  'default'    => '',
  'help|VF'    => 'LNER',
  'maxlen'     => 7,
  'name'       => 'LNER',
  'options'    => 'VF',
  'select'     => 'T',
  'size'       => 7,
  'sqlw'       => 'TRIM("$val_as")',
  'sort'       => true
);

$opts['fdd']['lne_pre']['sql|FV'] = 'concat(lne_pre,"",other_no,"",lner_suf)';

A result that should show fields 2 & 3 (169B) reports 169 AND a result that should show Fields 1 & 2 (023) reports 23 with 023 in a new column to the right with no header ?
I Have tried using both the other 2 fields as my start point but no joy.
To sum up I am not sure which field of the three I should use before using
Kód:
$opts['fdd']['lne_pre']['sql|FV'] = 'concat(lne_pre,"",other_no,"",lner_suf)';

And if both the other field should be there and how they sould be set up to work in unison

Sorry to be a pain

Regards
Roy...

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-08-08 17:54
Návrat hore  Odpovedať s citátom     

I'm out of ideas. If you post your entire script, maybe someone else can see the problem.

 
Topshed9     Založený: 14.01.2008   Príspevky: 34  
Príspevok Zaslal: 2009-08-13 03:52
Návrat hore  Odpovedať s citátom     

Thanks for the assistance, the problem was in the 'Options' => 'VLF'

to make it work only the first field needed

'Options' => 'VLF'

The other two required

'Options' => 'H'

Regards
Roy...

 
devkbsc     Založený: 30.12.2014   Príspevky: 7  
Príspevok Zaslal: 2015-02-24 14:54
Návrat hore  Odpovedať s citátom     

Hello,
Actually i am trying to do the same.

i have to create a username by concataning the first and last name.

I have tried this by using your final solution.But i have seen there is no change in the username col in the db table data.

here is my source code.

$opts['fdd']['username'] = array(
'default' => '',
'help|VF' => 'LNER',
'maxlen' => 7,
'name' => 'LNER',
'options' => 'H',
'select' => 'T',
'size' => 7,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['username']['sql|FV'] = 'concat(prenom,nom)';

username is a text field. please make a correction for me. thank you.

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2015-02-24 20:37
Návrat hore  Odpovedať s citátom     

What I fail to understand is why anyone would want to populate a database field using data which can be calculated from a dummy / virtual field in VLF modes. Sam Smith and Steve Smith will have the same username, which appears on the surface to be a flaw in design assuming the username field is intended to be unique.

Otherwise, a trigger used to calculate the username in Add mode (only) would probably be the best solution.

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov