modify server data

modify server data

jack_lunnjack_lunn Posts: 6Questions: 2Answers: 0

New to DataTables - it looks brilliant! I'm just a little bit stuck. I'm also new to PHP and MySQL which I want to use. I have set up my database in MySQL and I'm OK using PHP to extract the data and display/sort etc. with DataTables.
I've been stuck for a while now trying to update the data on my server.
Before I came here I was using POST between pages.
Does anyone know of a complete short sample I could work through?
It may be 'serverside processing' or 'aaData' or I may have to learn AJAX - just not sure how to go about it.

This question has accepted answers - jump to:

Answers

  • WoldereWoldere Posts: 17Questions: 3Answers: 2
    edited November 2014

    What do you mean by "update the data on my server"? What exactly were you doing with POST? Update/Edit data in the db?

  • jack_lunnjack_lunn Posts: 6Questions: 2Answers: 0

    I'm obviously missing something here!

    I have an MySQL database on my server.
    I have HTML/PHP code to go on several clients which will maintain the server data.
    I can use this client side code to display data and DataTables/JQuery to enhance the whole UI experience.

    After lots of research I can 'POST' between pages and although I haven't done it yet, I was expecting to use something like
    'SQL updat/delete' etc. to modify the server data.
    I just need some documentation or to look at sample code where all this can be achieved.

    I'm surprised that this isn't more well documented as it a situation to be solved by most of the users of 'DataTables'.
    This is why I say 'I'm obviously missing something'

    I hope I've explained this more clearly.

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    I don't understand this part:

    Before I came here I was using POST between pages

    Were you doing a full page reload and using POST to send the information required about the new page?

    I was expecting to use something like 'SQL updat/delete' etc. to modify the server data.

    Based on what data being submitted?

    It would be useful if you linked to an example page so we can understand what you are trying to do.

    Allan

  • jack_lunnjack_lunn Posts: 6Questions: 2Answers: 0

    I could link to some code but it's all pretty standard stuff.

    Some background....
    I came here from a number of years around C and later VBA.
    I have a small MSAccess system on a server/client config. with 6-8 users all accessing 'linked Access tables' on the server.
    I want to update my work using PHP, MySQL on a XAMPP server.
    All of this stuff I have a good understanding of and I present users with data from the server using mainly 'SELECT'.
    I thought some SQL such as UPDATE, after a client edit, would be all that was necessary to change server data and MySQL would handle such things as 'record locking'.

    I then bumped into DataTables which seems to take a lot of work away from developers - magic!.....
    I have spent a couple of days working through the sample codes and I'm slowly understanding the JQuery/DataTables samples.

    After the clients edit some of the data this must somehow be reflected on the server.
    I was expecting to find lots of samples how this can be achieved, but I seem to be digging a bigger hole!

    I think we should ignore any mention I've made of 'POST' as I'm not totally OK with it.
    I expect someone will say I have to learn AJAX and JSON etc. but I don't think there are enough brain cells left.

    I thought if I could find a flowchart/diagram of how this all works and maybe some code to demonstrate it I would be able to work through and modify it for my needs.

    I'm sorry if this is difficult to understand - I just wish I could make it clearer.

    In a nutshell...
    If I put some data in a text box on a client's screen, which came from a MySQL table on the server using PHP --- and then the user edits this textbox --- how to update the server?
    Where can I find some code to demonstrate this? - please.

  • jack_lunnjack_lunn Posts: 6Questions: 2Answers: 0

    I've just found something.......

    http://jquery-datatables-editable.googlecode.com/svn/trunk/customize-buttons.html

    This does almost every thing except update the server with any edited cells

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin
    Answer ✓

    how to update the server?

    DataTables won't do that. There is the Editor extension which adds editing abilities to the table.

    The plug-in you link in might work as well, but it is third party and not supported by myself and as far as I am aware it is no longer updated by its author.

    Allan

  • WoldereWoldere Posts: 17Questions: 3Answers: 2
    edited November 2014 Answer ✓

    With HTML, you can post a form.

    Then with PHP you can do something like this to add new data to your database.

    if(isset($_POST['something']) && isset($_POST['something_else']){
    $query = "INSERT INTO tablename VALUES ($_POST['something'], $_POST['something_else')]";
    } --- dont use this code, its just an example.

    This has nothing to do with datatables though, that's just html and PHP

    You could also use ajax via js to edit or delete something, example piece of code:

     if(confirmed == true){
     $.post("/path/to/ajax_delete",{json:JSON.stringify(deleteArray)},function(data){
            if(data.bool){
                $('#id06').html("<b>Deletion: successful<b>");
            $('#datatable-1').DataTable().ajax.reload();        
          } else {
            $('#id06').html("<b>Deletion: NOT successful<b>");
          }
     }, "json");
       }
    
  • jack_lunnjack_lunn Posts: 6Questions: 2Answers: 0

    Thanks Woldere and Allan for your help.
    I should have enough to be going on with - I'll come back here if I get any grief.
    Cheers

This discussion has been closed.