Checkboxes, add or.

I'm got a series of checkboxes and am automatically forming the query based off the selections.

I get this:

(Bowling like 'Right-arm fast') (Bowling like 'Right-arm fast-medium') (Bowling like 'Right-arm medium-fast') (Bowling like 'Right-arm medium') (Bowling like 'Right-arm slow') (Bowling like 'Right-arm slow-medium') (Bowling like 'Slow right-arm orthodox') (Bowling like 'Right-arm Leg-break')

But I need to automatically add "OR" in between all the statements.

Is there a way I can automate that?
PeterErhardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
Wheres your code
0
PeterErhardAuthor Commented:
Sorry, here we are.

//*************Check Fast******************

	//Check Right Arm
	if ($BoxBowlingStyleRightArm != "")
	{
		$boxbowling.= " (Bowling like 'Right-arm";
	}

	//Check Fast
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleFast != "")
	{
		$boxbowling.= " fast')";
	}

	//Check Left Arm
	if ($BoxBowlingStyleLeftArm != "")
	{
		$boxbowling.= " (Bowling like 'Left-arm";
	}

	//Check Fast
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleFast != "")
	{
		$boxbowling.= " fast')";
	}

	//Check Under Arm
	if ($BoxBowlingStyleUnderArm != "")
	{
		$boxbowling.= " (Bowling like 'Under-arm";
	}

	//Check Fast
	if ($BoxBowlingStyleUnderArm != "" && $BoxBowlingStyleFast != "")
	{
		$boxbowling.= " fast')";
	}

	//Check Round Arm
	if ($BoxBowlingStyleRoundArm != "")
	{
		$boxbowling.= " (Bowling like 'Round-arm";
	}

	//Check Fast
	if ($BoxBowlingStyleRoundArm != "" && $BoxBowlingStyleFast != "")
	{
		$boxbowling.= " fast')";
	}

	//Check if No Bowling Type
	if ($BoxBowlingStyleFast != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "" && $BoxBowlingStyleUnderArm == "" && $BoxBowlingStyleRoundArm == "")
	{
		$boxbowling.= " (Bowling like '%fast%' and Bowling not like '%fast-%' and Bowling not like '%-fast%')";
	}

	if (strpos($boxbowling,')') == false)
	{
		$boxbowling = "";
	}

	$finalboxbowling .= $boxbowling;

	$boxbowling = "";

//*************Check Medium******************

	//Check Right Arm
	if ($BoxBowlingStyleRightArm != "")
	{
		$boxbowling.= " (Bowling like 'Right-arm";
	}

	//Check Fast-Medium
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleFast != "" && $BoxBowlingStyleMedium != "")
	{
		$boxbowling.= " fast-medium')";
		$boxbowling.= " (Bowling like 'Right-arm medium-fast')";
	}

	//Check Medium
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleMedium != "")
	{
		if (strpos($boxbowling,')') == false)
		{
			$boxbowling.= " medium')";
		}
		else
		{
			$boxbowling.= " (Bowling like 'Right-arm";
			$boxbowling.= " medium')";
		}
	}

	//Check Left Arm
	if ($BoxBowlingStyleLeftArm != "")
	{
		$boxbowling.= " (Bowling like 'Left-arm";
	}

	//Check Fast-Medium
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleFast != "" && $BoxBowlingStyleMedium != "")
	{
		$boxbowling.= " fast-medium')";
		$boxbowling.= " (Bowling like 'Left-arm medium-fast')";
	}

	//Check Medium
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleMedium != "")
	{
		if (strpos($boxbowling,')') == false)
		{
			$boxbowling.= " medium')";
		}
		else
		{
			$boxbowling.= " (Bowling like 'Left-arm";
			$boxbowling.= " medium')";
		}
	}

	//Check Under Arm
	if ($BoxBowlingStyleUnderArm != "")
	{
		$boxbowling.= " (Bowling like 'Under-arm";
	}

	//Check Fast-Medium
	if ($BoxBowlingStyleUnderArm != "" && $BoxBowlingStyleFast != "" && $BoxBowlingStyleMedium != "")
	{
		$boxbowling.= " fast-medium')";
		$boxbowling.= " (Bowling like 'Under-arm medium-fast')";
	}

	//Check Medium
	if ($BoxBowlingStyleUnderArm != "" && $BoxBowlingStyleMedium != "")
	{
		if (strpos($boxbowling,')') == false)
		{
			$boxbowling.= " medium')";
		}
		else
		{
			$boxbowling.= " (Bowling like 'Under-arm";
			$boxbowling.= " medium')";
		}
	}

	//Check Round Arm
	if ($BoxBowlingStyleRoundArm != "")
	{
		$boxbowling.= " (Bowling like 'Round-arm";
	}

	//Check Fast-Medium
	if ($BoxBowlingStyleRoundArm != "" && $BoxBowlingStyleFast != "" && $BoxBowlingStyleMedium != "")
	{
		$boxbowling.= " fast-medium')";
		$boxbowling.= " (Bowling like 'Round-arm medium-fast')";
	}

	//Check Medium
	if ($BoxBowlingStyleRoundArm != "" && $BoxBowlingStyleMedium != "")
	{
		if (strpos($boxbowling,')') == false)
		{
			$boxbowling.= " medium')";
		}
		else
		{
			$boxbowling.= " (Bowling like 'Right-arm";
			$boxbowling.= " medium')";
		}
	}

	//Check if No Bowling Type
	if ($BoxBowlingStyleMedium != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "" && $BoxBowlingStyleUnderArm == "" && $BoxBowlingStyleRoundArm == "")
	{
		$boxbowling.= " (Bowling like '%medium%' and Bowling not like '%medium-%' and Bowling not like '%-medium%')";
	}
	if ($BoxBowlingStyleMedium != "" && $BoxBowlingStyleFast != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "" && $BoxBowlingStyleUnderArm == "" && $BoxBowlingStyleRoundArm == "")
	{
		$boxbowling.= " (Bowling like '%fast-medium%' and Bowling like '%medium-fast%')";
	}

	if (strpos($boxbowling,')') == false)
	{
		$boxbowling = "";
	}

	$finalboxbowling .= $boxbowling;

	$boxbowling = "";

//*************Check Slow******************

	//Check Right Arm
	if ($BoxBowlingStyleRightArm != "")
	{
		$boxbowling.= " (Bowling like 'Right-arm";
	}

	//Check Slow
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleSlow != "")
	{
		$boxbowling.= " slow')";
	}

	//Check Slow-Medium
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleSlow != "" && $BoxBowlingStyleMedium != "")
	{
		$boxbowling.= " (Bowling like 'Right-arm slow-medium')";
	}

	//Check Left Arm
	if ($BoxBowlingStyleLeftArm != "")
	{
		$boxbowling.= " (Bowling like 'Left-arm";
	}

	//Check Slow
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleSlow != "")
	{
		$boxbowling.= " slow')";
	}

	//Check Slow-Medium
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleSlow != "" && $BoxBowlingStyleMedium != "")
	{
		$boxbowling.= " (Bowling like 'Left-arm slow-medium')";
	}

	//Check Under Arm
	if ($BoxBowlingStyleUnderArm != "")
	{
		$boxbowling.= " (Bowling like 'Under-arm";
	}

	//Check Slow
	if ($BoxBowlingStyleUnderArm != "" && $BoxBowlingStyleSlow != "")
	{
		$boxbowling.= " slow')";
	}

	//Check Slow-Medium
	if ($BoxBowlingStyleUnderArm != "" && $BoxBowlingStyleSlow != "" && $BoxBowlingStyleMedium != "")
	{
		$boxbowling.= " (Bowling like 'Under-arm slow-medium')";
	}

	//Check Round Arm
	if ($BoxBowlingStyleRoundArm != "")
	{
		$boxbowling.= " (Bowling like 'Round-arm";
	}

	//Check Under Arm
	if ($BoxBowlingStyleUnderArm != "")
	{
		$boxbowling.= " (Bowling like 'Under-arm";
	}

	//Check Slow
	if ($BoxBowlingStyleUnderArm != "" && $BoxBowlingStyleSlow != "")
	{
		$boxbowling.= " slow')";
	}

	//Check Slow-Medium
	if ($BoxBowlingStyleUnderArm != "" && $BoxBowlingStyleSlow != "" && $BoxBowlingStyleMedium != "")
	{
		$boxbowling.= " (Bowling like 'Round-arm slow-medium')";
	}

	//Check if No Bowling Type
	if ($BoxBowlingStyleSlow != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "" && $BoxBowlingStyleUnderArm == "" && $BoxBowlingStyleRoundArm == "")
	{
		$boxbowling.= " (Bowling like '%slow%' and Bowling not like '%slow-%' and Bowling not like '%-slow%')";
	}
	if ($BoxBowlingStyleSlow != "" && $BoxBowlingStyleMedium != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "" && $BoxBowlingStyleUnderArm == "" && $BoxBowlingStyleRoundArm == "")
	{
		$boxbowling.= " (Bowling like '%slow-medium%')";
	}

	if (strpos($boxbowling,')') == false)
	{
		$boxbowling = "";
	}

	$finalboxbowling .= $boxbowling;

	$boxbowling = "";

//*************Check Orthodox******************

	//Check Right Arm
	if ($BoxBowlingStyleRightArm != "")
	{
		$boxbowling.= " (Bowling like 'Slow right-arm";
	}

	//Check Orthodox
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleOrthodox != "")
	{
		$boxbowling.= " orthodox')";
	}

	//Check Left Arm
	if ($BoxBowlingStyleLeftArm != "")
	{
		$boxbowling.= " (Bowling like 'Slow left-arm";
	}

	//Check Orthodox
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleOrthodox != "")
	{
		$boxbowling.= " orthodox')";
	}

	//Check if No Bowling Type
	if ($BoxBowlingStyleOrthodox != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "")
	{
		$boxbowling.= " (Bowling like '%orthodox%')";
	}

	if (strpos($boxbowling,')') == false)
	{
		$boxbowling = "";
	}

	$finalboxbowling .= $boxbowling;

	$boxbowling = "";


//*************Check Leg-Break******************

	//Check Right Arm
	if ($BoxBowlingStyleRightArm != "")
	{
		$boxbowling.= " (Bowling like 'Right-arm";
	}

	//Check Orthodox
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleLegBreak != "")
	{
		$boxbowling.= " Leg-break')";
	}

	//Check Left Arm
	if ($BoxBowlingStyleLeftArm != "")
	{
		$boxbowling.= " (Bowling like 'Left-arm";
	}

	//Check Orthodox
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleLegBreak != "")
	{
		$boxbowling.= " Leg-break')";
	}

	//Check if No Bowling Type
	if ($BoxBowlingStyleLegBreak != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "")
	{
		$boxbowling.= " (Bowling like '%Leg-break%')";
	}

	if (strpos($boxbowling,')') == false)
	{
		$boxbowling = "";
	}

	$finalboxbowling .= $boxbowling;

	$boxbowling = "";

//*************Check Off-Break******************

	//Check Right Arm
	if ($BoxBowlingStyleRightArm != "")
	{
		$boxbowling.= " (Bowling like 'Right-arm";
	}

	//Check Orthodox
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleOffBreak != "")
	{
		$boxbowling.= " Off-break')";
	}

	//Check Left Arm
	if ($BoxBowlingStyleLeftArm != "")
	{
		$boxbowling.= " (Bowling like 'Left-arm";
	}

	//Check Orthodox
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleOffBreak != "")
	{
		$boxbowling.= " Off-break')";
	}

	//Check if No Bowling Type
	if ($BoxBowlingStyleOffBreak != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "")
	{
		$boxbowling.= " (Bowling like '%Off-break%')";
	}

	if (strpos($boxbowling,')') == false)
	{
		$boxbowling = "";
	}

	$finalboxbowling .= $boxbowling;

	$boxbowling = "";

//*************Check Chinaman******************

	//Check Right Arm
	if ($BoxBowlingStyleRightArm != "")
	{
		$boxbowling.= " (Bowling like 'Slow right-arm";
	}

	//Check Orthodox
	if ($BoxBowlingStyleRightArm != "" && $BoxBowlingStyleChinaman != "")
	{
		$boxbowling.= " chinaman')";
	}

	//Check Left Arm
	if ($BoxBowlingStyleLeftArm != "")
	{
		$boxbowling.= " (Bowling like 'Slow left-arm";
	}

	//Check Orthodox
	if ($BoxBowlingStyleLeftArm != "" && $BoxBowlingStyleChinaman != "")
	{
		$boxbowling.= " chinaman')";
	}

	//Check if No Bowling Type
	if ($BoxBowlingStyleChinaman != "" && $BoxBowlingStyleRightArm == "" && $BoxBowlingStyleLeftArm == "")
	{
		$boxbowling.= " (Bowling like '%chinaman%')";
	}

	if (strpos($boxbowling,')') == false)
	{
		$boxbowling = "";
	}

	$finalboxbowling .= $boxbowling;

	$boxbowling = "";

echo $finalboxbowling;

Open in new window

0
Ray PaseurCommented:
Please show us the HTML document that contains the checkboxes, thanks.  A URL or the actual HTML will be perfect.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

PeterErhardAuthor Commented:
The above is the php and here's the html

<td colspan="2">

Bowling Style<br>

<?php

	echo "<input type='checkbox' name='BoxBowlingStyleRightArm' value='Right-arm'>Right-arm";
	echo "<input type='checkbox' name='BoxBowlingStyleLeftArm' value='Left-arm'>Left-arm";
	echo "<input type='checkbox' name='BoxBowlingStyleUnderArm' value='Under-arm'>Under-arm";
	echo "<input type='checkbox' name='BoxBowlingStyleRoundArm' value='Round-arm'>Round-arm";
	echo "<input type='checkbox' name='BoxBowlingStyleFast' value='Fast'>Fast";
	echo "<input type='checkbox' name='BoxBowlingStyleMedium' value='Medium'>Medium";
	echo "<input type='checkbox' name='BoxBowlingStyleSlow' value='Slow'>Slow";
	echo "<input type='checkbox' name='BoxBowlingStyleOrthodox' value='Orthodox'>Orthodox";
	echo "<input type='checkbox' name='BoxBowlingStyleLegBreak' value='Leg-break'>Leg-break";
	echo "<input type='checkbox' name='BoxBowlingStyleOffBreak' value='Off-break'>Off-break";
	echo "<input type='checkbox' name='BoxBowlingStyleChinaman' value='Chinaman'>Chinaman";

?>

</td>

Open in new window

0
GaryCommented:
I would just do a quick replace at the end
$finalboxbowling=str_replace(") (",") OR (",$finalboxbowling);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PeterErhardAuthor Commented:
Thanks Gary, good simple solution :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.