Following code will print table of 3 on click Print but you can pass number as parameter to function to print for any number:
<button onclick="printTable()"> Print </button>
<script>
function printTable(){
var result ="<?php php_func(); ?>"
document.write(result);
}
</script>
<?php
function php_func(){
$NUM = 3;
for($i=1;$i<=10;$i++){
$product = $i*$NUM;
echo "$NUM * $i = $product" ;
echo '<br>';
}
}
?>