I’ve been working on something recently in which the testing has involved modiyfing 2 or 3 fields in a database very regularly, I was fed-up of going into phpMyAdmin clicking edit on the row, finding the field (1 of 100 odd), editing it and then going to the save button.

I decided that I would write a Greasemonkey script to turn all of the fields into an AJAX editing form.

Basically all you have to do now is double click the field value, edit the value and hit enter to save!

It has only been tested on phpMyAdmin 3.1.2 so I have no idea if it’ll work on other versions.

This script uses jQuery (www.jquery.com).

// ==UserScript==
// @name           Ajax PHPMyAdmin
// @namespace      All
// @description    Ajaxify PHPMyAdmin By Joel Day http://blog.dayjo.org/
// @include        http://localhost/phpmyadmin/sql.php*
// ==/UserScript==

// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; // Or specify one on the local server for a quicker load
GM_JQ.type = 'text/javascript';

// Check if jQuery's loaded
function GM_wait() {
    if (typeof unsafeWindow.jQuery == 'undefined') {
        window.setTimeout(GM_wait, 100);
    else {
        $ = unsafeWindow.jQuery;

// All your GM code must be inside this function
function letsJQuery() {

    var i = 0, j = 0;

    // Assign the th's id for later so we can grab the field name
    $('#table_results').find('th:not([colspan])').each(function() {

    	// i represents a column id
        i++; $(this).attr('id', i);


// Loop through the field values and re-make the
 into our input box and div
    $('#table_results').find('td:not([align="center"])').each(function() {

        // Assign it a column id
        if (j == i) {
            j = 0;

    	// Current value of the field
        var value = $(this).html();
        var field = $('#' + j + ' a').html();

        // Set the html
        $(this).html("<div name='fielddiv'>" + value + "</div>\
        	<input style='display: none; text-align: right;' type='text' title='" + field + "' value='" + value + "' />");

// Set the dblclick event of the div
$('#table_results div[name="fielddiv"]').dblclick(function(){

// Show the input and hide the div


// Loop through and set the ENTER keypress event for save
    $('#table_results').find('td:not([align="center"]) input').keypress(function(ev) {
        if (ev.keyCode == 13) {
        	// Get the info for the query.
            var db = $('input[name="db"]').val();
            var table = $('input[name="table"]').val();
            var token = $('input[name="token"]').val();
            var field = $(this).attr('title');
            var value = $(this).val();
            var ID = $(this).parent().siblings().children('input[title="ID"]').val();

// Post the query
            $.post("sql.php?db=" + db + "&table=" + table + "&sql_query=UPDATE+" + table + "+SET+" + field + "='" + value + "'+WHERE+`ID`='" + ID + "'&token=" + token);

            // Now set the div to the new value, show it and hide the input

// Return false as not to post any forms or click any selected links
            return false;

In this day and age, I would have thought everyone would want a website, cafe’s, restaurants, bars, shops etc, but it seems not. I’m currently trying to find some web design work to keep the money flowing (currently draining), and have had a single phone call about it.

I don’t know whether or not my advertising is crap, or if people just don’t want websites.. either way, no work as of yet.

So just to plug myself, and hopefully get some results on Google as a Professional Brighton Web Designer, I post this blog (and of course to say hi).

So, I offer my services to one and all;

Standard Hourly Rate: £30 ph

Friend and Family Discount: 40%
Small Business Discount: 20%

Web Design & Development, including Content Management Systems, Blogs, Forums, etc.
Hosting and Domain Management is available.

Normally I work on a 3 part payment Contract, whereas 1 3rd is paid upfront, then the other 2 3rds are paid sequentially after confirming designs/pages, and finaly product.

Please don’t hesitate to phone or email;

Joel Day