Q:

How to use javascript to output tables every 1 second? 

I want to make something like tables which refresh every 1 second and show to all the users on the website. 
You see, like, when the user loads the page, every 1 second, a new table row gets added to the table on the body.  He should be able to see that change without having to refresh manually or press F5. 
Here is what I have tried, returns an empty page:
<html>
<head></head>
<body>
<script type="text/javascript">
function myFunction()
{
    <? php

        echo "<tr>";
        echo "<td>Hey</td>";
        echo "</tr>";
    ? >
}
setTimeout(myFunction, 1000);
</script>
</body>
</html>

A:

Server code will only generate a table row for every response; you need to either send multiple responses using ajax, or get a collection of data to loop through using PHP if you're filling the table with data. 
A simple non-data way to achieve your current functionality using only Javascript is like so:
    function rowGenerator(){

// Find a <table> element with id="myTable":
var table = document.getElementById("myTable");

// Create an empty <tr> element and add it to the 1st position of the table:
var row = table.insertRow(0);

// Insert new cells (<td> elements) at the 1st and 2nd position of the "new" <tr> element:
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);

// Add some text to the new cells:
cell1.innerHTML = "NEW CELL1";
cell2.innerHTML = "NEW CELL2";

}

setInterval(rowGenerator, 1000);

