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

 RESOLVED-IF statement help

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 04/25/2011, 3:56 PM

Right now I have this:
$grade = $Component->$grade->GetValue();  
  
if ( $grade IN ('5th','6th','7th') )  
{  
$Component->Label2->SetValue("!5th,6th,7th!");  
}

I swear it worked for a awhile.. but now it is throwing an error.

Is that invalid PHP?

If so.. how do I get it to do what I want?


_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
damian

Posts: 838
Posted: 04/26/2011, 2:01 AM

the error may be in line 1 with too much money...

what is it you are trying to do? are you trying to set label2 to the same value as grade if grade is 5th, 6th or 7th?
if so then i would try:

$mygrade = $Component->grade->GetValue();    
    
if ( $mygrade IN ('5th','6th','7th') )    
{    
$Component->Label2->SetValue($Component->grade->GetValue());    
}

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
ckroon

Posts: 869
Posted: 04/26/2011, 6:57 AM

Thanks Damian... sorry for the confusion.
Let's try again.

Here is the code I am playing with...

$grade = $Component->grade->GetValue();  
  
if ( $grade IN ('5th','6th','7th') )  
{ echo "YES!";  
}  
else  
{  
echo "NO!";  
}

I get a Parse Error.
But for the life of me cannot see where the issue is.


_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
datadoit
Posted: 04/26/2011, 8:20 AM

I'm not familiar with an if 'in' command in PHP. There's an if in_array
command:

$grade = $Component->grade->GetValue();
$grades = array("5th", "6th", "7th");
if (in_array($grade, $grades)) {
echo "YES!";
}
else {
echo "NO!";
}

Also note how you're referring to the CodeCharge object. If you're
using form or record server-side events, refer to the field objects as:

$Container->grade->GetValue();

If you're using field server-side events, refer to the field as:

$Component->GetValue();
ckroon

Posts: 869
Posted: 04/26/2011, 2:38 PM

Perfect!
Thanks!
_________________
Walter Kempees...you are dearly missed.
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.

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.