Solved

IF Statement not working

Posted on 2008-06-12
8
244 Views
Last Modified: 2013-12-13
Having a trouble with an IF statement.

if my price is 20
there pricecode is b - it should = 21
there pricecode is f - it should = 22

for some reason its always showing the $market value

when i echo $CustGroup->value it shows B00 like it should be, but its not adding 1.
$CustGroup = $rs2->Fields("Pricecode");

$market = $rs->Fields("market1");
 

if ($CustGroup->value =="B00") {

	$adjustedprice = (float)$market->value + 1;

	}

if ($CustGroup->value =="F00") {

	$adjustedprice = (float)$market->value + 2;

	}

else {

	$adjustedprice = (float)$market->value;

	}

Open in new window

0
Comment
Question by:SuprSpy79
8 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 21772130
try:
$CustGroup = $rs2->Fields("Pricecode");

$market = $rs->Fields("market1");

 

if ($CustGroup- =="B00") {

	$adjustedprice = (float)$market->value + 1;

	}

if ($CustGroup =="F00") {

	$adjustedprice = (float)$market->value + 2;

	}

else {

	$adjustedprice = (float)$market->value;

	}

Open in new window

0
 
LVL 5

Author Comment

by:SuprSpy79
ID: 21772146
i have to use ->value because im working with an ADODB object (prob should have said that up front)
0
 
LVL 5

Author Comment

by:SuprSpy79
ID: 21772166
also to reiterate -

echo $CustGroup->value shows B00

(for the current customer im testing)
0
 
LVL 4

Expert Comment

by:afzz
ID: 21772203
just do a echo as shown and see what value is picked up from the variable.

If it is BOO then try by changing this like this

$adjustedprice = (float)($market->value + 1);
$market = $rs->Fields("market1");

echo $CustGroup->value;

if ($CustGroup->value =="B00") {

        $adjustedprice = (float)$market->value + 1;

        }

if ($CustGroup->value =="F00") {

        $adjustedprice = (float)$market->value + 2;

        }

else {

        $adjustedprice = (float)$market->value;

        }

Open in new window

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 48

Expert Comment

by:hernst42
ID: 21772217
what does the output of
echo serialize($CustGroup->value);
show?
0
 
LVL 5

Author Comment

by:SuprSpy79
ID: 21772251
s:3:"B00";
0
 
LVL 4

Accepted Solution

by:
afzz earned 500 total points
ID: 21772257
Try changing your code to the following. It is a simple mistake as it is BOO the next condition gets into else always
if ($CustGroup->value =="B00") {

        $adjustedprice = (float)$market->value + 1;

        }

elseif ($CustGroup->value =="F00") {

        $adjustedprice = (float)$market->value + 2;

        }

else {

        $adjustedprice = (float)$market->value;

        }

Open in new window

0
 
LVL 5

Author Comment

by:SuprSpy79
ID: 21772337
that was it afzz. Its really weird though because I had this exact code working and i just changed stuff around it, oh well atleast its working. Thanks :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now