Jump to content

[SOLVED] ***Conditional If and Or Statement


Grodo

Recommended Posts

Hello

 

Thanks for looking at my post...

 

So here is the scoop.  I have three checkboxes (toolmag,sinkmag,faucetmag).  What I am trying to do is have php check if one or more of the checkboxes are checked.  I akready got the validation code down now all that is left is to form the IF and Or statement. This is the part im lost one.  I know that if statments can have multiple conditions. But how can you tell the if statement if this condition is not met go to the next and when non of the conditions meet go to the else.  I know that in Java the operator was ||.  Attached below is the checkbox html code as well as the php code for checkbox validation.

 

   <input type="checkbox" name="toolmag">Tool Catalog<BR>

   <input type="checkbox" name="sinkmag">Vanity / Stainless Steel Sink Catalog<BR>

   <input type="checkbox" name="faucetmag">Faucet Catalog<BR>

 

// CheckBox Tool Cat
if($_POST['toolmag']) {
	$tm=1;
} else {
	$tm=0;
}
// CheckBox Sink Cat
if($_POST['sinkmag']) {
	$sm=1;
} else {
	$sm=0;
}
// CheckBox Faucet Cat
if($_POST['faucetmag']) {
	$fm=1;
} else {
	$fm=0;
}

Link to comment
Share on other sites

Ok I figured it out had to use a ghetto if statement (HEY IT WORKS) Still open for suggestions!

 

//Check if one of the boxes is selected
If ($tm==1) {
	// Do Nothing
}
elseif ($fm==1) {
	// Do Nothing
}
elseif ($sm==1) {
	// Do Nothing
}
else {
	$print_again = true;
	$message[]="Please select a catalog";
}

Link to comment
Share on other sites

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.