Topshed9
Založený: 14.01.2008
Príspevky: 34
Zaslal: 2012-07-12 05:50
Návrat hore
Odpovedať s citátom
|
I want to replace 0 ie: zeros in a numeric field with " " or NULL to stop columns of zeros appearing
The code for the field is
| Kód: |
$opts['fdd']['46_p'] = array(
'default' => '',
'help|ACP' => 'Limit 1 characters',
'input' => '',
'maxlen' => 1,
'name' => '',
'options' => 'ACPVDFL',
'select' => 'T',
'size' => 1,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
|
I have bneen trying to get a result with variations of the following
| Kód: |
$opts['fdd']['46_p'] = array(
if {
'default' => '',
'help|ACP' => 'Limit 1 characters',
'input' => '',
'maxlen' => 1,
'name' => '',
'options' => 'ACPVDFL',
'select' => 'T',
'size' => 1,
'sqlw' => 'TRIM("$val_as" = 0)',
'sort' => true,
else )
'default' => '',
'help|ACP' => 'Limit 1 characters',
'input' => '',
'maxlen' => 1,
'name' => '',
'options' => 'ACPVDFL',
'select' => 'T',
'size' => 1,
'sqlw' => '("$val_as" = " ")',
'sort' => true
);
|
No matter what I always get an error on the "if" line
"if { "
Any guidance on the correct syntax, or if I am up the wrong alley would be most helpful.
Thanx
Roy...
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2012-07-12 16:12
Návrat hore
Odpovedať s citátom
|
An array() has to be an array ... you can't do if{else} in the manner you've tried.
Try this:
| Kód: |
$opts['fdd']['46_p'] = array(
'default' => '',
'help|ACP' => 'Limit 1 characters',
'input' => '',
'maxlen' => 1,
'name' => '',
'options' => 'ACPVDFL',
'select' => 'T',
'size' => 1,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
// post-initialization sometimes makes it easier to read/modify
$opts['fdd']['46_p']['sql|LF'] = 'if(46_p = "0", "-", 46_p)'; |
|
Topshed9
Založený: 14.01.2008
Príspevky: 34
Zaslal: 2012-07-15 08:12
Návrat hore
Odpovedať s citátom
|
Hi Doug, Thank you for the reply, unfortunatly that did not fix my problem.
I can get the result from the table involved, I just do not understand why I cannot then produce a Var and print the var over the oniginal
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2012-07-15 15:51
Návrat hore
Odpovedať s citátom
|
An example follows, from a script which was conveniently available, and it replaces N from db content with a hyphen (-). Works fine.
| Kód: |
$opts['fdd']['deleted'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => 'N',
'input' => '',
'maxlen' => 1,
'name' => 'Deleted',
'options' => 'ACPVFL',
'required' => false,
'select' => 'D',
'sqlw' => 'TRIM("$val_as")',
'values' => array('N','Y'),
'sort' => true,
'tab|ACPV' => 'Deleted',
);
// MySQL column 24: string - enum('N','Y')
$opts['fdd']['deleted']['sql|LF'] = 'if(deleted = "N", "-", deleted)'; |
|
|
Odoslať novú tému
Odpovedať na tému
|
|