Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sql = "UPDATE tbl_sample SET ".$column_name."='".$text."' WHERE id='".$id."'";
- $(document).ready(function(){
- function fetch_data()
- {
- $.ajax({
- url:"dbselect.php",
- method:"POST",
- success:function(data){
- $('#live_data').html(data);
- }
- });
- }
- fetch_data();
- $(document).on('click', '#btn_add', function(){
- var desc = $('#desc').text();
- var ipadd = $('#ipadd').text();
- var port = $('#port').text();
- var platform = $('#platform').text();
- if(desc == '')
- {
- alert("Enter Description");
- return false;
- }
- if(ipadd == '')
- {
- alert("Enter IP Address");
- return false;
- }
- if(port == '')
- {
- alert("Enter Port Number");
- return false;
- }
- if(platform == '')
- {
- alert("Enter DB Platform");
- return false;
- }
- $.ajax({
- url:"dbinsert.php",
- method:"POST",
- data:{desc:desc, ipadd:ipadd, port:port, platform:platform},
- dataType:"text",
- success:function(data)
- {
- alert(data);
- fetch_data();
- }
- })
- });
- function edit_data(id, text, column_name)
- {
- $.ajax({
- url:"dbedit.php",
- method:"POST",
- data:{id:id, text:text, column_name:column_name},
- dataType:"text",
- success:function(data){
- alert(data);
- }
- });
- } $(document).on('blur', '.desc', function(){
- var id = $(this).data("id1");
- var desc = $(this).text();
- edit_data(id, desc, "desc");
- });
- $(document).on('blur', '.ipadd', function(){
- var id = $(this).data("id2");
- var ipadd = $(this).text();
- edit_data(id,ipadd, "ipadd");
- });
- $(document).on('blur', '.port', function(){
- var id = $(this).data("id3");
- var port = $(this).text();
- edit_data(id,port, "port");
- });
- $(document).on('blur', '.platform', function(){
- var id = $(this).data("id4");
- var platform = $(this).text();
- edit_data(id,platform, "platform");
- });
- $(document).on('click', '.btn_delete', function(){
- var id=$(this).data("id5");
- if(confirm("Are you sure you want to delete this?"))
- {
- $.ajax({
- url:"dbdelete.php",
- method:"POST",
- data:{id:id},
- dataType:"text",
- success:function(data){
- alert(data);
- fetch_data();
- }
- });
- }
- });
- });
- <?php
- $connect = pg_connect("host=localhost dbname=dbinv user=postgres password=moira port=5432");
- $sql = "INSERT INTO "kbc".dbinventory(desc,ipadd,port,platform)
- values ('".$desc."','".$ipadd."','".$port."','".$platform."')";
- if(pg_query($connect, $sql))
- {
- echo 'Data Inserted';
- }
- ?>
- <?php
- $connect = mysqli_connect("localhost", "root", "", "test_db");
- $id = $_POST["id"];
- $text = $_POST["text"];
- $column_name = $_POST["column_name"];
- $sql = "UPDATE tbl_sample SET ".$column_name."='".$text."' WHERE id='".$id."'";
- if(pg_query($connect, $sql))
- {
- echo 'Data Updated';
- }
- ?>
- ERROR: ERROR: syntax error at or near "Reilly"
Add Comment
Please, Sign In to add comment