Guest User

Untitled

a guest
Oct 26th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. $sql = "UPDATE tbl_sample SET ".$column_name."='".$text."' WHERE id='".$id."'";
  2.  
  3. $(document).ready(function(){
  4. function fetch_data()
  5. {
  6. $.ajax({
  7. url:"dbselect.php",
  8. method:"POST",
  9. success:function(data){
  10. $('#live_data').html(data);
  11. }
  12. });
  13. }
  14. fetch_data();
  15. $(document).on('click', '#btn_add', function(){
  16. var desc = $('#desc').text();
  17. var ipadd = $('#ipadd').text();
  18. var port = $('#port').text();
  19. var platform = $('#platform').text();
  20.  
  21. if(desc == '')
  22. {
  23. alert("Enter Description");
  24. return false;
  25. }
  26. if(ipadd == '')
  27. {
  28. alert("Enter IP Address");
  29. return false;
  30. }
  31.  
  32. if(port == '')
  33. {
  34. alert("Enter Port Number");
  35. return false;
  36. }
  37.  
  38. if(platform == '')
  39. {
  40. alert("Enter DB Platform");
  41. return false;
  42. }
  43. $.ajax({
  44. url:"dbinsert.php",
  45. method:"POST",
  46. data:{desc:desc, ipadd:ipadd, port:port, platform:platform},
  47. dataType:"text",
  48. success:function(data)
  49. {
  50. alert(data);
  51. fetch_data();
  52. }
  53. })
  54. });
  55. function edit_data(id, text, column_name)
  56. {
  57. $.ajax({
  58. url:"dbedit.php",
  59. method:"POST",
  60. data:{id:id, text:text, column_name:column_name},
  61. dataType:"text",
  62. success:function(data){
  63. alert(data);
  64. }
  65. });
  66. } $(document).on('blur', '.desc', function(){
  67. var id = $(this).data("id1");
  68. var desc = $(this).text();
  69. edit_data(id, desc, "desc");
  70. });
  71. $(document).on('blur', '.ipadd', function(){
  72. var id = $(this).data("id2");
  73. var ipadd = $(this).text();
  74. edit_data(id,ipadd, "ipadd");
  75. });
  76.  
  77. $(document).on('blur', '.port', function(){
  78. var id = $(this).data("id3");
  79. var port = $(this).text();
  80. edit_data(id,port, "port");
  81. });
  82.  
  83. $(document).on('blur', '.platform', function(){
  84. var id = $(this).data("id4");
  85. var platform = $(this).text();
  86. edit_data(id,platform, "platform");
  87. });
  88.  
  89. $(document).on('click', '.btn_delete', function(){
  90. var id=$(this).data("id5");
  91. if(confirm("Are you sure you want to delete this?"))
  92. {
  93. $.ajax({
  94. url:"dbdelete.php",
  95. method:"POST",
  96. data:{id:id},
  97. dataType:"text",
  98. success:function(data){
  99. alert(data);
  100. fetch_data();
  101. }
  102. });
  103. }
  104. });
  105. });
  106.  
  107. <?php
  108. $connect = pg_connect("host=localhost dbname=dbinv user=postgres password=moira port=5432");
  109. $sql = "INSERT INTO "kbc".dbinventory(desc,ipadd,port,platform)
  110. values ('".$desc."','".$ipadd."','".$port."','".$platform."')";
  111. if(pg_query($connect, $sql))
  112. {
  113. echo 'Data Inserted';
  114. }
  115. ?>
  116.  
  117. <?php
  118. $connect = mysqli_connect("localhost", "root", "", "test_db");
  119. $id = $_POST["id"];
  120. $text = $_POST["text"];
  121. $column_name = $_POST["column_name"];
  122. $sql = "UPDATE tbl_sample SET ".$column_name."='".$text."' WHERE id='".$id."'";
  123. if(pg_query($connect, $sql))
  124. {
  125. echo 'Data Updated';
  126. }
  127. ?>
  128.  
  129. ERROR: ERROR: syntax error at or near "Reilly"
Add Comment
Please, Sign In to add comment