I have a javascript that loads the contents of a DIV when checking a Checkbox and passes a variable.
I retrieve the variable with $color = $_GET['color'];
and then I do a few IFs to pick my query:
if ($color != '')
{
if ($sortBy != '')
{
$items = mysql_query("SELECT * FROM item_descr WHERE color_base1 = '$color' ORDER BY '$sortBy' DESC");
}
else
{
$items = mysql_query("SELECT * FROM item_descr WHERE color_base1 = $color");
echo $color;
$result = mysql_query($items) or die(mysql_error());
}
}
Every time the $result is returning "Quert was empty" even if $color contains a value.
Note: I have tried to put $color in the query like this too: '$color' and also '".$color."'. Didn´t work Would you have any idea of what's going on?
Thanks!
WHERE color_base1='#92462f'
(change the color value to a value that is in the DB)? Does it work without the WHERE-part of the clause?