I can display the table directly on the form, but I need it to be displayed only when I press a key, and then I can return to the start page.

<table border="0" style="width:100%"> <tr> <th>Позиция</th> <th>Имя</th> <th>Очки</th> </tr> <?php require("processing.php"); $db = new DB(); $result = $db->selectAllScores(); //$numrows = $result->num_rows; if($result){ // echo $result; $count = 1; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>". $count ."</td>"; echo "<td>". $row['username'] ."</td>"; echo "<td>". $row['score'] ."</td>"; echo "</tr>"; $count++; if($count == 11) { break; } } } ?> </table> 

Alas, friends with JS are bad, so I didn’t figure out what to do with the output of tables

    2 answers 2

    Use Ajax:

     $('#myActionButton').click(function(){ $.post( "/скрипт/который/будет/добавлять/таблицу.php", { myActionName: "Выполнить" } ); }); 
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <button id="myActionButton">Выполни</button> 

    Take out the creation of the table in a separate file and replace the path. There are no other ways to add a table without updating.

      to do this, you need to make a button on the page, hang on it JS handler, which sends AJAX request to the server, the necessary information will be received on the server side, the table body will be formed and it will return to your original template

      • And how not to explain? - ʞɔᴉN ɹǝꓥ