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
https://forums.phpfreaks.com/topic/104907-solved-conditional-if-and-or-statement/
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";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.