Jump to content

Recommended Posts

:-[ I have a HTML form with a series of 7 check boxes that have been passed to a php page where for each of the check boxes "ticked" I wish to increment a total by a different value depending on the check box ticked.

I have a test page ( code below ) which proves that the check boxes have been ticked and I am using a 'while' statement to check if the box has been ticked and if so increment a total.

PROBLEM is that the while statement runs continously when true.  I expected it to go through once and then step on to the next  statement but it loops for ever!.

After a successful while statement ( that is the condition is true ) do I have to 'disable' the value ( make the condition false )?

Help!

<?php
$newline = "<br>";
echo " Start of Living Room Selection. " ;
echo $newline;
echo " Total so far ";
$lrtotal = 25000;
echo $lrtotal;
echo $newline;
echo "Switch value = ";
echo ($_POST['option1']);
echo $newline;
echo ($_POST['option2']);
echo $newline;
echo ($_POST['option3']);
echo $newline;
echo ($_POST['option4']);
echo $newline;
echo ($_POST['option5']);
echo $newline;
echo ($_POST['option6']);
echo $newline;
echo ($_POST['option7']);
echo $newline;
$TwoSeaterSofa = 1.00;
$ThreeSeaterSofa = 9.00;
echo "Twoseater literal is ";
echo $TwoSeaterSofa;
echo $newline;
echo "Threeseater literal is ";
echo $ThreeSeaterSofa;
echo $newline;

while (($_POST['option1'])== true)
    {echo ($_POST['option1']);
 $lrtotal = $lrtotal + $TwoSeaterSofa;
 echo $lrtotal;
 echo $newline;
     }
while (($_POST['option2'])== true)
    {echo ($_POST['option2']);
 $lrtotal = $lrtotal + $ThreeSeaterSofa;
 echo $lrtotal;
 echo $newline;
      }

// 5 more while statementsfor $_POST [option3 to 7 ] in here.



echo " Total for living room ";
echo $lrtotal;
echo $newline;
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.