Variable in the SQL query

0

Well, I'm trying to query with a variable I'm getting, but it's not working. Any suggestions?

$model = $_REQUEST['model'];
$customer = $_REQUEST['customer'];
SELECT * FROM sistema WHERE concluido <> 1 AND site='$site' AND $model='X'
    
asked by anonymous 21.07.2015 / 20:46

1 answer

3

Work out as follows:

$model = $_REQUEST['model'];
$customer = $_REQUEST['customer'];

$consulta = "SELECT * FROM sistema WHERE concluido <> 1 AND site = '{$site}' AND {$model} = 'X'";

Do not forget to check if the variables are coming correctly and if the comparison signal is actually <> , you might want to use = '1' .

    
21.07.2015 / 20:55