|
-
Feb 6th, 2012, 02:38 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Echoing conditional messages once
Hi Folks,
I created this code below that I want to use in a for loop statement with an if statement. This might not be the best way to go about it, but it does work somehow. However, I have a problem with it. When I run the page, the code runs well only I have the output 'Proceed to checkout' in infinity. It keeps echoing proceed to checkout without stopping and I get a long page with the same text message. Sometime, it crashes.
Code:
<?php
$accountBalance = 560;
$cost = 123;
$pay = $accountBalance - $cost;
$msg = "You have insufficient money in your account.";
$accept = "Proceed to checkout";
$refuse = "Credit your account to continue.";
for (;;) {
if ($pay <= $accountBalance) {
echo $accept;
}
else
{
if ($pay > $accountBalance)
{
echo $msg . $refuse;
}
}
}
?>
Can someone help me out with any idea so that is echos 'Proceed to checkout' or any other output just once, please?
Thanks,
Menre
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|