i would like my mysql query to be different depending on the content of a php variable (session) it has to be something like:
if ($_SESSION['session_id'] != NULL) {
$var1 = "and id = '$_SESSION[session_id]'";
}
$result = mysql_query("
SELECT field1, field2
FROM table
WHERE name = '$_GET[name]' $var1
") or die(mysql_error());
which will be: WHERE name = '$_GET[name]' and id = '$_SESSION[session_id]'
or: WHERE name = '$_GET[name]'
how can i do this? Thanks.