JavaScript Code, PHP Code, SQL Code

Edit MySQL database tables with PHP and AJAX

Every week I look at the PHP Classes newsletter to see if there are any cool new submissions. This one is perhaps the most exciting and promising that I've seen in a while!

I blogged a while ago about a PHP Datagrid class. Basically, it's an easy way to interact with the data in a table (view, add, modify records), without having to build an interface from scratch. However, the class turned out to be a pain to implement, I never got it to work fully.

So, my next venture will be to implement this new class: DBNavigator.

Like the PHP Datagrid class, it can be used to browse and modify data in a MySQL database. The cool difference is that is uses an AJAX interface to edit, insert, and search the MySQL database tables! I was looking for a demo on the author's site, but couldn't find it (the site's in Italian). But it boasts some cool features:

  • Update and delete multiple records at once.
  • Prevent editing/deleting records by simultaneous users (locking).
  • Records can be data-bound to form inputs.
  • Javascript for browser-side validation, as well as server-side validation.
  • Uploading files to specific folders, and ensuring that the uploaded files don't exist already.
  • List and search for records to be edited or deleted. Search fields support AJAX based auto-complete suggestions. Search results can be saved to CSV files.
  • Pagination (paging) links in tables with different colors or CSS styles for different rows.

Hopefully this one will be easier to implement!

Share

10 Comments

  1. I tried to no avail. Good luck to you tho. I was suckered in by the ideal of NOT having to customize an interface every time I add a new field to a DB that really should be managed by that department and not me. I cutcopyandpaste a lot of code and then just hack it to work for that particular department – but that gets ugly after awhile. Best of luck

  2. Get urban sniper 2 and treasure of cutlass reef

  3. It's quite easy to implement. It proves to be very useful too.

  4. i got it work
    its pretty cool i am going to modify it with new css and better data. notice that the export feature doesn't work. i have had that issue before and got it to work on my own. i don't really know if its that cool. i haven't decided yet. let me know if u have any questions on how to implement. heres how i did it.
    1) Get the HTMLFORM Class
    2) Get the Pagenavigator class
    3) Get the dBNavigator class
    4) put all the files in the same folder
    5) put all the images in an img folder
    6) create the tables in the .sql file provided
    7) change the dB connection strings in example_full.php and index.php
    8) rock and roll

  5. hi
    i need code for using multiple tables(add,edit,delete) in ajax with php

  6. please i need help i really someone who can give me a script which i can use browse search and delete records on my website.If anyone is interested in helping me,please let the person visiy my website http://www.beautyheritagenaija.com and tell me what he or she can do.Please i also need a script that can display data from my sql database to a webpage and also it will have a search feature to search specific records according to ID admin@beautyheritagenaija.com

  7. I think if someone makes a simple and easy application for adding, updating, and deleting database record entries, that can easily be implemented to any webpage they will make lots of people very happy.

  8. Hello james apply this code for deleting record after this you can do everything using this code just u have knowledge about jquery and ajax

    delete_random.php
    Contains PHP code displaying records from database. Take a look at class="delete_button"

    <a href="#" id="" class="delete_button">X

    jQuery code
    Contains javascipt code. $(".delete_button").click(function(){}- delete_button is the class name of anchor tag (X). Using element.attr("id") calling delete button value. If id value is even number if(id(even) % 2) = If(0) false

    $(function() {
    $(".delete_button").click(function() {
    var id = $(this).attr("id");
    var dataString = 'id='+ id ;
    var parent = $(this).parent();

    $.ajax({
    type: "POST",
    url: "deleteajax.php",
    data: dataString,
    cache: false,

    success: function()
    {
    if(id % 2)
    {
    parent.fadeOut('slow', function() {$(this).remove();});
    }
    else
    {
    parent.slideUp('slow', function() {$(this).remove();});
    }
    }
    });

    return false;
    });
    });

    deleteajax.php
    Contains PHP code. Delete record from the database.

    CSS Code
    *{margin:0;padding:0;}
    ol.update
    {
    list-style:none;font-size:1.2em;
    }
    ol.update li
    {
    height:50px; border-bottom:#dedede dashed 1px;
    }
    ol.update li:first-child
    {
    border-top:#dedede dashed 1px; height:50px;
    }
    #main
    {
    width:500px; margin-top:20px; margin-left:100px;
    font-family:"Trebuchet MS";
    }
    .delete_button
    {
    margin-left:10px;
    font-weight:bold;
    float:right;
    }

  9. how to show field database but the namae is link and if i click link name will go to edit form?

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image