Niel Sarvari
Niel Sarvari

Reputation: 113

How can I allow admins to edit a db table on their site's backend?

I am developing a site where admins can log in and then view the database tables for various clients registered on the site. These admins should then be able to edit these values on the page that they're viewing it.

Is there a way that I can implement it so that they can simply click on the value that they want to edit, and then it will automatically update in the database? They shouldn't be redirected to a different page. It should be similar to phpmyadmin's inline editing.

I've tried to work with Editable Grid, but with very little documentation it is very difficult for me to understand how I can implement it correctly.

Upvotes: 0

Views: 114

Answers (2)

Erik
Erik

Reputation: 2264

If you're looking for a good library to accomplish this then I would recommend using something like this http://www.sprymedia.co.uk/article/KeyTable together with jQuery and Ajax. The KeyTable library provides very nice in line editing.

Upvotes: 0

Daniel Li
Daniel Li

Reputation: 15389

You'll need to implement an AJAX solution to accomplish this. Mozilla's documentation has a great overview of how to use this:

Reference: https://developer.mozilla.org/en-US/docs/AJAX

Using jQuery, you can send data easily via an $.ajax call:

$.ajax({
  type: "POST",
  url: "insert_into_database.php",
  data: { name: "Foo", location: "bar" }
}).done(function( msg ) {
  alert( "Data Saved: " + msg );
});

Upvotes: 3

Related Questions