CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 info display question

Print topic Send  topic

Author Message
kirchaj

Posts: 215
Posted: 11/10/2007, 4:54 AM

How would one go about masking out part of a field in a grid? We have a system that contains ssn's and ids and we would like to hide most of the ssn while being displayed in the grid. So instead of showing 987654321 we would like it to show XXXXXX4321. We need to store this information in the db for reporting purposes but do not want to display it completely in the grid.

Any ideas on how to do this?

Can't wait for 4.0!!!

TK
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 11/11/2007, 10:49 PM

kirchaj
I am assuming that you are using MySQL. If this is the case what you can do is have the datasource format the field for you then all you have to do is place the field in the data grid. Here is an example of what you can do:

Select Fname, Lname, Address, City, State, Zip, concat('xxxxx',RIGHT(SSN,4)) as UserSSN
from UserTable

Hopefully this helps you.
View profile  Send private message
kirchaj

Posts: 215
Posted: 11/12/2007, 5:54 AM

mambobrown,

Thanks for the idea. I am actually using postgres. So I am sure there is a similar way for this to work.

I am also concerned because I need the field to update information on the student. So my idea was to have a hidden field used for updating and another similar label I could use for display.

Am I doing this the hardest way?

Is there not a way to do this as part of a CCS function?

Thanks again.

TK
View profile  Send private message
wkempees
Posted: 11/12/2007, 5:18 PM

K,
MB's solution is a good solid valid option, us it.

However if you are in need to retain the original value, for update
purposes, your approach is as good.
I would retreive the full value from the database, store it in a session
(CCSetSession()), as well as doing the Mambo.
Then change the Update procedure to be a Custom Update and update your
tablerow using that session variable. This way the full ssn is not visible
(hidden fields are visible when using ViewSource, Sessionvariables are not).
It would take some extra work, but hey you asked for it!

Another approach would be to use str_replace, or even regular expressions, I
could even think of truncating the display label.

Several ways to reach the goal, but not as a CCS function.

Walter

kirchaj

Posts: 215
Posted: 11/13/2007, 1:03 PM

Walter,

Thanks for the advice. I think your more complex solution will be in the next version :) It is something I am concerned about but can't convert to right now.

What I decided to do is use the before show row event with the following command

$ssnostring = $currentstudent->ssno->GetValue();
$currentstudent->ssno->SetValue((substr_replace("$ssnostring","XXXXX",0,5)));

I know I can do this in one statement but haven't gone back to fix that yet.

Thanks again for the help and I may be asking for more help when I get to the session issues.

TK
View profile  Send private message
aondecker

Posts: 58
Posted: 11/13/2007, 1:26 PM

Quote kirchaj:
Walter,

Thanks for the advice. I think your more complex solution will be in the next version :) It is something I am concerned about but can't convert to right now.

What I decided to do is use the before show row event with the following command

$ssnostring = $currentstudent->ssno->GetValue();
$currentstudent->ssno->SetValue((substr_replace("$ssnostring","XXXXX",0,5)));

I know I can do this in one statement but haven't gone back to fix that yet.

Thanks again for the help and I may be asking for more help when I get to the session issues.

TK

You dont even need to assign it to a hidden field.

$currentstudent->ssno->SetValue((substr_replace($currentstudent->ssno->GetValue(),"XXXXX",0,5)));

This will do the trick without having to worry about your Hidden field showing up and/or making a session variable.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.