CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 set field to values from other fields

Print topic Send  topic

Author Message
freddie
Posted: 03/02/2004, 8:25 AM

I want to take three fields and set the contents of a forth field to these fields on an insert or update of a mysql record.

i.e. field1 = "123456" field2 = "987" field3 = "001"

resulting field4 shoud be = "123456-987-001"

How and where do I code this assignment?

Thanks
aradi

Posts: 66
Posted: 03/02/2004, 10:52 AM

The following SQL can do it using MySql:

UPDATE Dbtable SET field1 = '123456',field2 = '987',field3 = '001',field4 = CONCAT_WS( "-", field1, field2, field3 );

or if the values of field1,field3,field3 already set then this will update field4:

UPDATE DBtable SET field4 = CONCAT_WS( "-", field1, field2, field3 );
View profile  Send private message
freddie
Posted: 03/02/2004, 4:14 PM

okay but where in CCS do I put this code????

And what about doing it with php?
RonB
Posted: 03/08/2004, 11:08 AM

On Tue, 02 Mar 2004 08:25:43 -0800, freddie wrote:

> I want to take three fields and set the contents of a forth field to these fields on an insert or update of a mysql record.
>
> i.e. field1 = "123456" field2 = "987" field3 = "001"
>
> resulting field4 shoud be = "123456-987-001"
>
> How and where do I code this assignment?
>
> Thanks
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
In before show row:
$gridname->field4->setvalue($gridname->field1->GetValue() ."-"
..$gridname->field2->GetValue() ."-" . $gridname->field3->GetValue() );

RonB
Si Cranmer
Posted: 03/09/2004, 12:10 AM

The extra DB updates need to be fired in
AfterUpdate & AfterInsert events
OR
If you make field4 a DB field then CCS will automaticaly updated/insert it to the DB so you can just do
$gridname->field4->setvalue($gridname->field1->GetValue() ."-"
..$gridname->field2->GetValue() ."-" . $gridname->field3->GetValue() );
in BeforeUpdate & BeforeInsert events.

HTH

Si.

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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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