NightWheeler Posted May 29, 2014 Share Posted May 29, 2014 Hello, Here is my current code: index.php <html> <body> <form id="hey" name="hey" method="post" onsubmit="return false"> Name:<input type="text" name="name"> <input type="submit" name="submit" value="click"> </form> <table class="table table-bordered" id="update"> <thead> <th>Name</th> </thead> <tbody> <script type="text/javascript"> $("#hey").submit(function() { $.ajax({ type: 'GET', url: 'response.php', data: { username: $('#name').val()}, success: function (data) { $("#update").prepend(data); }, error: function (xhr, ajaxOptions, thrownError) { alert(thrownError); } }); }); </script> </tbody> </table> response.php <?php $username = $_GET['username']; echo "<tr>"; echo "<td>$username</td>"; echo "</tr>"; ?> This code works fine, it prints out the rows as what the user enters. Now what I want to do is, log all these entries to a mySQL database and also, display these rows over the site. i.e., any user who is online, should be seeing this without having to refresh the page too.. Real time updates in a way. How can I achieve that? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/288867-save-each-record-into-database-and-then-update-table-for-all-users/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.