Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Sunday, October 18, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Replacing a fied result when printing with a defaul reponse

phpMyEdit General     Replacing a fied result when printing with a defaul reponse
Post new topic   Reply to topic    
 
Topshed9     Joined: 14 Jan 2008   Posts: 34  
Post Posted: 2012-07-12 05:50
Back to top  Reply with quote     

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
Code:

$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
Code:

$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     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2012-07-12 16:12
Back to top  Reply with quote     

An array() has to be an array ... you can't do if{else} in the manner you've tried.

Try this:

Code:
$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     Joined: 14 Jan 2008   Posts: 34  
Post Posted: 2012-07-15 08:12
Back to top  Reply with quote     

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     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2012-07-15 15:51
Back to top  Reply with quote     

An example follows, from a script which was conveniently available, and it replaces N from db content with a hyphen (-). Works fine.

Code:
$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)';


 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy