Advertisement
Guest User

Untitled

a guest
May 20th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>MySQL Table Manager With Bootstrap/jQuery/Ajax/PHP/MySQL</title>
  6. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  7. </head>
  8. <body>
  9.  
  10. <div class="container" style="margin-top: 30px;">
  11.  
  12. <div id="tableManager" class="modal fade">
  13. <div class="modal-dialog">
  14. <div class="modal-content">
  15. <div class="modal-header">
  16. <h2 class="modal-title">Country Name</h2>
  17. </div>
  18.  
  19. <div class="modal-body">
  20. <input type="text" class="form-control" placeholder="Country Name..." id="countryName"><br>
  21. <textarea class="form-control" id="shortDesc" placeholder="Short Country Description"></textarea><br>
  22. <textarea class="form-control" id="longDesc" placeholder="Long Country Description"></textarea><br>
  23. </div>
  24.  
  25. <div class="modal-footer">
  26. <input type="button" onclick="manageData('addNew')" value="Save" class="btn btn-success">
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31.  
  32. <div class="row">
  33. <div class="col-md-8 col-md-offset-2">
  34. <h2>MySQL Table Manager</h2>
  35.  
  36. <input style="float: right" type="button" class="btn btn-success" id="addNew" value="Add New">
  37. <br><br>
  38. <table class="table table-hover table-bordered">
  39. <thead>
  40. <tr>
  41. <td>ID</td>
  42. <td>Country Name</td>
  43. <td>Options</td>
  44. </tr>
  45. </thead>
  46. <tbody>
  47.  
  48. </tbody>
  49. </table>
  50.  
  51. </div>
  52. </div>
  53. </div>
  54.  
  55. <script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  56. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  57. <script type="text/javascript">
  58. $(document).ready(function() {
  59. $("#addNew").on('click', function () {
  60. $("#tableManager").modal('show');
  61. });
  62.  
  63. getExistingData(0, 10);
  64. });
  65.  
  66. function getExistingData(start, limit) {
  67. $.ajax({
  68. url: 'ajax.php',
  69. method: 'POST',
  70. dataType: 'text',
  71. data: {
  72. key: 'getExistingData',
  73. start: start,
  74. limit: limit
  75. }, success: function (response) {
  76. if (response != "reachedMax") {
  77. $('tbody').append(response);
  78. start += limit;
  79. getExistingData(start, limit);
  80. }
  81. }
  82. });
  83. }
  84.  
  85. function manageData(key) {
  86. var name = $("#countryName");
  87. var shortDesc = $("#shortDesc");
  88. var longDesc = $("#longDesc");
  89.  
  90. if (isNotEmpty(name) && isNotEmpty(shortDesc) && isNotEmpty(longDesc)) {
  91. $.ajax({
  92. url: 'ajax.php',
  93. method: 'POST',
  94. dataType: 'text',
  95. data: {
  96. key: key,
  97. name: name.val(),
  98. shortDesc: shortDesc.val(),
  99. longDesc: longDesc.val()
  100. }, success: function (response) {
  101. alert(response);
  102. }
  103. });
  104. }
  105. }
  106.  
  107. function isNotEmpty(caller) {
  108. if (caller.val() == '') {
  109. caller.css('border', '1px solid red');
  110. return false;
  111. } else
  112. caller.css('border', '');
  113.  
  114. return true;
  115. }
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. </script>
  126. </body>
  127. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement