lo siento por mi mal inglés, google me ayuda :-) con mi script, si ingreso algo en la base de datos, se muestra sin recargar la página. Ahora quería preguntar si esto es tan bueno o se puede mejorar. Conozco javascript/Ajax y lo que no existe. Solo quiero que si se escribe algo en la base de datos con un formulario, se muestre inmediatamente sin recargar la página, como una especie de caja de mensajes.
<!DOCTYPE html> <html lang="de" dir="ltr"> <head> <meta charset="utf-8"> <title>Ausgabe</title> </head> <body onload = "table();"> <script type="text/javascript"> function table(){ const xhttp = new XMLHttpRequest(); xhttp.onload = function(){ document.getElementById("table").innerHTML = this.responseText; } xhttp.open("GET", "system.php"); xhttp.send(); } setInterval(function(){ table(); }, 1); </script> <div id="table"> </div> </body> </html> <?php $host_name = ''; $database = ''; $user_name = ''; $password = ''; $link = new mysqli($host_name, $user_name, $password, $database); if ($link->connect_error) { die('<p>Verbindung zum MySQL Server fehlgeschlagen: '. $link->connect_error .'</p>'); } $rows = mysqli_query($link, "SELECT * FROM tb_data"); ?> <table border = 1 cellpadding = 10> <tr> <td>#</td> <td>Name</td> </tr> <?php $i = 1; ?> <?php foreach($rows as $row) : ?> <tr> <td><?php echo $i++; ?></td> <td><?php echo $row["name"]; ?></td> </tr> <?php endforeach; ?> </table>