how to get this case working in php?

Not working case (the one I want to work):
I have a table where I store where clause to be used in my php code.

It is stored as string in table's field `"WHERECLAUSE"`:

```
"where WEEK = '$weeknum'  AND YEAR = '$year'"

```

I select string value from table's field "WHERECLAUSE" put into the variable 

php code :

```
   $TABLE = 'REASSORT';
   $whereclause =  "where WEEK = '$weeknum'  AND YEAR = '$year'";

     // create the select query
   $query = "select * FROM $TABLE " . $whereclause;

```

when I `echo $query` I get --> 

```
 select * FROM REASSORT where WEEK = '$weeknum'  AND YEAR = '$year'

```

This returns no data from table "REASSORT", because variables `$weeknum` and `$year` are rendered as strings. 

working case I expect:

PHP code:

```
$whereclause = " where WEEK = '$weeknum'  AND YEAR = '$year' ";
$query = "select * FROM $TABLE " . $whereclause;

```

when I echo $query I get --> 

```
select * FROM REASSORT where WEEK = '4' AND YEAR = '2019'

```

And data is returned from table "REASSORT"

Thanks in advance for your help.