Pass variable from js to php

How to pass a variable from js to php?
I have that code
?>

<?php $partw=var_export("",true); echo $partw; sc_select_where(add)="where fname=".$partw; echo $partw; shows me a value but using this value whit sc_select_where it contain the whole script

From my understanding you have to pass it via a GET or a POST as PHP is server side and JS is client.

Good afternoon @edfenech .
The question is how?

Ajax call.
Have a look how jquery works. It is very easy to make an Ajax call from javascript.to a PHP script passing what you want