Greetings from Sweden, where I'm stuck on something that the sharper among you will correctly recognize as pretty basic! I appreciate very much your help.
Here's a simplified version of the problem. On one page, there's a simple advanced search function where users can specify one, both or neither of two fields, each with two drop-down menu options:
<form action="results.php" method="POST">
Some records in the database have only a size specified; some have only a color specified; some have both; and importantly, some have neither.
Where I'm stuck is in writing code that returns results as follows:
If the user selects a size, all returned results should have that size.
If the user selects a color, all returned results should have that color.
If the user selects both size and color, all returned results should have both that size and that color.
If the user selects neither size nor color, then there should be no results, even those records that themselves have neither size nor color specified.
I suspect that success will come from a well written query line, which the following disaster of mine clearly is not:
$query="SELECT * FROM table WHERE size='$size' OR color='$color'";
I have read through these forum posts and have tried to better understand PHP operators, but truly am stuck. Thank you for reading!:)