CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Replace value with text

Print topic Send  topic

Author Message
duetltd

Posts: 7
Posted: 10/16/2007, 1:24 PM

I am trying to display a table which has a value in one column (store products - is recommended) the column contains a 0 (for no) and a 1 (for yes). I would like to simply display a Yes or a No on the table rather than a 0 or a 1.

I had assumed I would set up a global string and change it as each record is displayed but I cannot figure out how to do that.

Another option would be to create a function that takes a parameter (0 or 1) and returns the text (yes or no) and use that function in the sql definition?

Thanks.

Don
View profile  Send private message
aondecker

Posts: 58
Posted: 10/16/2007, 1:30 PM

On the label or textbox or whatever your control is, just add an before-show event.

In the event put something like this.

If ( control ==0)
control->setText("NO")
else
control->setText("YES");
View profile  Send private message
datadoit
Posted: 10/16/2007, 3:03 PM

duetltd wrote:
> I am trying to display a table which has a value in one column (store products -
> is recommended) the column contains a 0 (for no) and a 1 (for yes). I would like
> to simply display a Yes or a No on the table rather than a 0 or a 1.
>
> I had assumed I would set up a global string and change it as each record is
> displayed but I cannot figure out how to do that.
>
> Another option would be to create a function that takes a parameter (0 or 1)
> and returns the text (yes or no) and use that function in the sql definition?
>
> Thanks.
>
> Don
> ---------------------------------------

Did you try setting the label type to Boolean? Choose display type
Yes/No, then DBFormat 1/0.
wkempees
Posted: 10/16/2007, 7:33 PM

"datadoit" <datadoit@forum.codecharge> schreef in bericht
news:ff3cft$4n5$1@news.codecharge.com...
> duetltd wrote:
>> I am trying to display a table which has a value in one column (store
>> products -
>> is recommended) the column contains a 0 (for no) and a 1 (for yes). I
>> would like
>> to simply display a Yes or a No on the table rather than a 0 or a 1.
>>
>> I had assumed I would set up a global string and change it as each record
>> is
>> displayed but I cannot figure out how to do that.
>>
>> Another option would be to create a function that takes a parameter (0 or
>> 1)
>> and returns the text (yes or no) and use that function in the sql
>> definition?
>>
>> Thanks.
>>
>> Don
>> ---------------------------------------
>
> Did you try setting the label type to Boolean? Choose display type
> Yes/No, then DBFormat 1/0.

the right way!
Walter

RonB

Posts: 228
Posted: 10/18/2007, 2:00 AM

if you are using mysql you can use the if statement in the query to do this.

Select if(field1=0,'no','yes') from table

this means your query will return the values you need and you will not need to do any php programming at all.

Oracle has a simular function called decode that works like this:
select decode(field1,0,'no',1,'yes') from table

Letting the database do the work is the fastest way.
View profile  Send private message
oracolo

Posts: 3
Posted: 10/18/2007, 7:32 AM

The solution of "aondecker" is better than "decode", for me.

If you use "control" and "setText", you can translate with "internationalize" {res:Yes} or {res:No}

bye
_________________
Using: CodeCharge Studio 3.2.0.4 - Apache, PHP and ORACLE
View profile  Send private message
duetltd

Posts: 7
Posted: 10/18/2007, 8:14 AM

Thanks all for your help.

Should "control" be replaced with the field name?

If so is it in this format?

$tablename->fieldname

Don
View profile  Send private message
duetltd

Posts: 7
Posted: 10/18/2007, 4:37 PM

I have been unable to get anything to work on IIS - but on the ubuntu machine the sql statement worked great. I have set up the 2003 to publish to the ubuntu and will get back to this on Sat.

Thanks again everyone.

Don
View profile  Send private message
aondecker

Posts: 58
Posted: 10/19/2007, 5:15 AM

Quote :
Thanks all for your help.
Should "control" be replaced with the field name?

If so is it in this format?

$tablename->fieldname

Don

Yes the control should be in that format.

Lets say the Table name is NewRecord1 and the Label is Label1, the code would look like this.


if ($NewRecord1->Label1->GetValue() == 0)
$Newrecord1->Label1->SetValue("No");
else
$NewRecord1->Label1->SetValue("Yes");

(If your control is a Label, make sure you set the data type in the properties tab to Text)
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.

Web Database

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.