Cant figure out how to code this in php
<p>I am trying to <code>$_GET</code> some variables that a user may enter (busy making a basic web-server):</p>

<pre><code>$users= strval($_GET['user']);
$price= intval($_GET['price']);
$productID= intval($_GET['productid']);
</code></pre>

<p>This is my query:</p>

<pre><code>$query = "SELECT * FROM `table` WHERE `user` = '" . $user . "' AND `price` &lt;= " . $price . " AND `productID` = " . $productID; 
</code></pre>

<p>(something like this)</p>

<p>Given this theoretical link:</p>

<pre><code>www.example.com/api.php?price=300
</code></pre>

<p>And don't use the rest of the GET (user and productID) will automatically be filled with either 0 or '' (int/string).</p>

<p>So I thought I could use an <code>if</code> statement:</p>

<pre><code>if(price == 0){
   // change the query without the price as WHERE
}
</code></pre>

<p>But what if I have combinations of price and productID or productID and user as variables.</p>

<p>What is the best way to handle this? Maybe it's a stupid question but I can't figure it out. </p>
